I am working in a project in ASP.NET.
I want to cache the username for the first time when the user logs in. E.g: If the current user is logged in and visiting a particular page for the first time, there will be a popup window display, otherwise nothing happens.
The username should be stored in the client browser and remain valid until the user closes the browser.
My question is, what is the best approach of doing this?
Any limitations if I am using ASP.Net Cache to store the username?
For example:
Cache["myCache"] = username;
and remove the item from the cache when page loads for the first time.
if (!Page.IsPostBack)
{
Cache.Remove("myCache");
}
This is open for any comments. Thank you in advance.
Use a
HttpCookieand set the expiration as needed:ASP.NET Cookies Overview
How to: Write a Cookie
How to: Read a Cookie