Thursday, March 16, 2017

Laravel + AngularJS best practice to store sessions used for post request

I am working on a Laravel + AngularJS application and fairly new to this kind of setup. I wanted to know what is the best practice to store sessions such as user id, email, name, etc. that would be passed onto forms or ajax calls.

Normally, in PHP/Laravel, one would store it using $_SESSION['userId'] or $this->session()->set('userId', $userId); and just get it on the PHP backend to be passed as a parameter when doing a post request.

But what is the best way for a Laravel + AngularJS setup?

Cookies? Localstorage?

I cross out cookies as it cannot handle much information. As for localstorage, I find it too exposed on the client side as it could be easily seen when you inspect it.

Any more recommendations?



via basagabi

Advertisement