简体   繁体   English

Laravel使用Ajax获取请求清除会话数据

[英]Laravel clears session data with ajax get request

I have 2 laravel apps ,currently working on localhost 我有2个laravel应用程序,当前在本地主机上工作

  1. askspidy ( http://localhost/askspidy/public/ ) askspidy( http:// localhost / askspidy / public /
  2. askspidymailer ( http://localhost/askspidymailer/public ) askspidymailer( http:// localhost / askspidymailer / public

In askspidy app, i am using ajax get to fetch the data which is stored in askspidymailer app. 在askspidy应用程序中,我正在使用ajax get来获取存储在askspidymailer应用程序中的数据。

Below is code to fetch the content written in askspidymailer into askspidy app 以下是将Askspidymailer中编写的内容提取到askspidy应用程序中的代码

$.ajax({
          url: "http://localhost/askspidymailer/public/get-inbox/1",
          dataType: "json",
          type:"get",
          async: false,
          success: function(data) 
          {
            console.log(data);
            if(data!='NULL')
            {

              for (var i=0; i<data.length; i++) 
              {
                  var fromName = data[i].fromName;
                  var fromAddress = data[i].fromAddress;
                  var subject = (data[i].subject).substr(0,50); 
                  var date = data[i].date;


                  var row = $('<tr><td><input type=checkbox></td><td class=mailbox-star><a href=#><i class=fa fa-star text-yellow></i></a></td><td class=mailbox-name><a href=# title='+ fromAddress + '>' + fromName + '</a></td><td class=mailbox-subject>' + subject + '</td><td class=mailbox-attachment><i class=fa fa-paperclip></i></td><td class=mailbox-date>' + date + '</td></tr>');

                  $("#inboxtable").append(row);
              }
            }

          }});

but whenever this code is executed, the askspidy laravel app session data is deleted or session id is modified , not sure 但是只要执行此代码,就会删除askspidy laravel应用会话数据或修改会话ID,但不确定

because when i click on any other link in askspidy laravel app or refresh the current page it redirects me to login page automatically. 因为当我单击askspidy laravel应用程序中的任何其他链接或刷新当前页面时,它会自动将我重定向到登录页面。

I am not sure , if it's because we are connecting 2 different laravel apps or what? 我不确定,是否是因为我们要连接2个不同的laravel应用或什么? I have checked that if i use different url here then it works fine , but this url it somehow modifies/deletes session value 我已经检查过,如果我在这里使用其他网址,那么它可以正常工作,但是它以某种方式修改/删除了会话值

This might be affected due to same session cookie name in session config file. 这可能由于会话配置文件中的相同会话cookie名称而受到影响。

So to prevent this issue change the session cookie name in config/session.php 因此,为防止此问题,请在config/session.php更改会话cookie名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM