Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to know the concept of stay online in the login page.I want to implement the concept in my project...the login user must logged in if he leave the current system ..
Posted
Comments
bbirajdar 11-Oct-12 5:07am    
Set the session timeout to 10 years and maintain the session on the server
OriginalGriff 11-Oct-12 5:12am    
Bad boy! :laugh:
bbirajdar 11-Oct-12 5:24am    
;)
OriginalGriff 11-Oct-12 5:11am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

The user can stay logged in for some time, as long as they're on the same machine and using the same browser, by setting the session timeout to a longer period. This allows users to browse your site, go off to other sites, and come back, without having to log in again. A reasonable session timeout might be 30 or 60 minutes. Very long session timeouts are a bad idea, because (i) it leaves you more open to session hijacking, and (ii) the server needs to store all the information for every session that's still open.

For 'come back tomorrow and remember me', you need to set a cookie with a (non-predictable and long enough to not be easily brute forcable) re-login token in it (a GUID makes a good one). On the server side, store a table of token to username. When someone comes back to your site, in the authentication section for a non logged in user, check if that cookie is provided and valid; if so, log them in and remove the token (so they aren't reusable, reducing the chance of a reuse attack). At some point you need to set that cookie; you might as well do it on login.
 
Share this answer
 

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