Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Please give me your valuable answers
Posted 26-Feb-13 1:44am
Comments
ryanb31 at 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?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Session.Clear() clears the all session variables value whereas Session.Abandon() vanishes(kills) the session.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5


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....
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

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.
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 26 Feb 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid