Reputation: 698
We are using FormsAuthentication
for a login process.
I need to add some data to the Logged in users Session to use in all the pages.
It can be done using Session["variable"] = value
, but I read few articles that said not to use session variables with FormsAuthentication
.
Is there any similar alternative like Session["variable"]
to use with FormsAuthentication
?
Upvotes: 0
Views: 623
Reputation: 61
Hi there's a way with javascript that is localStorage or SessionStorge
window.localStorage.setItem("message", "Hello World!");
Upvotes: 0
Reputation: 52210
Consider using the UserData property of the FormsAuthenticationTicket, which is created, encrypted, and stored in the forms cookie if you are using ASP.NET forms authentication. The very purpose of this field is to store free form data of the sort you are describing.
Upvotes: 1
Reputation: 163
Using private key to encrypt data and store in cookie can be an alternative. For every request, you can perform checking by reading and decrypt (with the private key) the cookie variable.
Upvotes: 0