tadasajon
tadasajon

Reputation: 14846

How do I store a variable in the session from the browser using angular.js?

I need to add a key to my session object on the browser using angular.js. Is this possible?

Upvotes: 0

Views: 611

Answers (2)

gertas
gertas

Reputation: 17145

If you mean changing client-side session window.sessionStorage then just ad key-value with the object.

Otherwise if you want to change server-side session this needs some work. I assume you use some MVC framework. First create an action in a controller which logic should add key-value passed by parameter to you session. Map the action to some path. On client-side you should create service which makes $http.post call to that action path and value as data.

Security hint: Please don't parametrize key name unless you have some security checks server-side. This way malicious user won't be able to modify sensitive key-value in your sessions.

Upvotes: 0

Caio Cunha
Caio Cunha

Reputation: 23394

It's not possible to change your session from client side.

Upvotes: 1

Related Questions