Multiple sessions created: Laravel 5.3, vue, vue-resource

187 Views Asked by At

I'm using vue-resource to post to an api method (registered in routes/api.php) like so:

this.$http.post('api/method', data);

Inside the api/method I'm trying to write to the current session like so:

\Session::put('error', 'test');
\Session::save();

However, when the post to the api method is triggered instead of updating the existing session, it creates a new file in the /storage/framework/sessions/ directory.

Using XAMPP (Apache) on Windows 8.1

Any ideas?

Update: Adding the session/csrf stuff to the api middleware got me closer.. i think. It's no longer creating a separate session file. There is still a problem however.

When I trigger the api-method with vue-resource I see that the variable is added to the session. I can look at the session file and the value is there. However, when I refresh/navigate to a new page it disappears... from the same file. So, it's not like it's creating a new separate session. It appears to be rebuilding the session and not keeping the value.

0

There are 0 best solutions below