Vishal Shetty
Vishal Shetty

Reputation: 1668

Laravel clears session data with ajax get request

I have 2 laravel apps ,currently working on localhost

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

In askspidy app, i am using ajax get to fetch the data which is stored in askspidymailer app.

Below is code to fetch the content written in askspidymailer into askspidy app

$.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

because when i click on any other link in askspidy laravel app or refresh the current page it redirects me to login page automatically.

I am not sure , if it's because we are connecting 2 different laravel apps or what? I have checked that if i use different url here then it works fine , but this url it somehow modifies/deletes session value

Upvotes: 1

Views: 1292

Answers (1)

Rohan Kumar
Rohan Kumar

Reputation: 40639

This might be affected due to same session cookie name in session config file.

So to prevent this issue change the session cookie name in config/session.php

Upvotes: 5

Related Questions