Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I am creating website.
problem is when i login after few minutes user id is expire.
Please solve this problem.
Posted
Comments
Tushar sangani 10-Dec-14 1:50am    
Store the Id In Session And Set Session Time Out

you can store it in session Session["id"] = id;
 
Share this answer
 
1. In a ASP.NET application the session for the current user could expire after few or more minutes, based on the associated setting from web.config.

In order to fix this you should use the next setting from your web.config:
HTML
<sessionstate mode="InProc" cookieless="false" timeout="1440" />


2. If you want to preserve the user ID between postbacks, after the user login you should cache its value in the current Session like in the next example:
C#
Session["UserID"]= userID;

Then during the postabcks, when you need the user ID, you could access it form the Session cache like in the code below:
C#
int userID = (int)Session["UserID"];
 
Share this answer
 
Comments
T. Ramesh Kumar 10-Dec-14 1:59am    
What is maximum timeout for session
Thanks7872 10-Dec-14 2:06am    
Do you have access to google.com?
Member 11165607 10-Dec-14 2:07am    
0 maybe..
Raul Iloc 10-Dec-14 2:15am    
1 year, like Microsoft said in MSDN: http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.timeout(v=vs.110).aspx
T. Ramesh Kumar 10-Dec-14 2:28am    
Ok i try this.Thank you for solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900