3

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.

AnthonyRyan
  • 153
  • 1
  • 7
  • It may be that you need to start a Session in your API route in Kernel.php, see answer in this thread https://laracasts.com/discuss/channels/laravel/laravel-auth-with-vue – Scott Anderson Jan 03 '17 at 00:01
  • Updated original post. Got closer, but still something weird going on. – AnthonyRyan Jan 03 '17 at 13:32

0 Answers0