Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please give me your valuable answers
Posted
Comments
ZurdoDev 26-Feb-13 7:47am    
Depends on business scenarios. Did you lookup what they do? I assume you understand what they do so do you have a more specific question?

When the user clicks on Signout or logout we need to clear session. By default session expires after 20 min of ideal state.

Better to use login controls for this and handle "LoggedOut" and "LoggingOut" events of LoginStatus status control.
 
Share this answer
 
Session.Clear() clears the all session variables value whereas Session.Abandon() vanishes(kills) the session.
 
Share this answer
 
v2

When you want to clear your session data that time you can call these methods.

Especially while logout/signout you can call these methods if you you are storing user/login information in session.

Some differences are,

1.Session.Abandon() will end current session by firing Session_End and in the next
request, Session_Start will be fire.

2.Session.Clear( ) just clears the session data without killing it. With session.clear
variable is not removed from memory it just like giving value null to this session.

Session ID will remain same in both cases, as long as the browser is not closed.

It's best coding practice to clear your session after logout.

Thanks....
 
Share this answer
 
You use Session.Clear() when you dont want to end the session but rather just clear all the keys in the session and reinitialize the session.

Session.Clear() will not cause the Session_End eventhandler in your Global.asax file to execute.

But on the other hand Session.Abandon() will remove the session altogether and will execute Session_End eventhandler.

Session.Clear() is like removing books from the bookshelf

Session.Abandon() is like throwing the bookshelf itself.
 
Share this answer
 
 
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