Reputation: 14846
I need to add a key to my session object on the browser using angular.js. Is this possible?
Upvotes: 0
Views: 611
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