Furquan Saifi
Furquan Saifi

Reputation: 1

Where can i store session variable in angular without having to call an api?

My backend is in php laravel 5.4, i want to use my session variables in my angular/ionic project the same way i use it in my blade files i.e by using $_SESSION['variable_name']

I have not found a way till now, the only way i have got till now is by calling an api and using this:

localStorage.setItem('sessionToken', response.sessionToken);

Upvotes: 0

Views: 599

Answers (1)

ml59
ml59

Reputation: 1641

Since Angular is a front end framework (executed on the client side in the Browser), you cannot have direct access to the session.
PHP Session are for backend code (aka server side, executed on the server).
You must retrieve the value through an api call and store it on the front end (cookie, local storage etc)

Upvotes: 5

Related Questions