I suggest to you to use a token and don't rely on session if you working with Angular.
Simple reason: Just imagine that session timeouts and you still pushing data from Angular Next level reason: As soon as you thinking of API calls ( REST ) you need to try to avoid session dependency.
If you put Bearer token into your request header it is much more nicer - and soon - simpler.
Hi @tothsanka, I'm aware of your suggestion but my usage of session is not related to authentication.
The real problem is that I'm working with Facebook login in order to get an authorization token from Facebook.
I'm using this library: https://github.com/SammyK/LaravelFacebookSdk
Debugging the app I realized that the session wasn't persisted.
What I explained was the isolated problem, which is the session wasn't persisted when the laravel resource is called through AngularJS.
So any other suggestion regarding my issue?
Thanks in advance!
Try the following in your config file, add this :
App.config(['$httpProvider', function ($httpProvider) { $httpProvider.defaults.withCredentials = true; }])
I am thinking maybe angular is not sending the headers needed for Laravel to identify your session...
I understand that. Once I got similar issue and that case I pushed FB accessToken to server and asked SDK to deliver the user. I deleted that build from github, but it was handy and no local copy.
Hi @mrj936, I tried your suggestion but it doesn't work.
I've printed the session ID in the ajax call and the directly browser call and I get the same session ID, so the session is the same. But I don't get the session value.
To write a session value I use Session::put('var_name', var_value'); and for retrieve it: Session::get('var_name');
Is that ok?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community