Session clear the object method comparison

 

Session clear the object method comparison
   http://blog.csdn.net/dongzhiquan/article/details/5446965

Session.Abandon (delete after the end of the current page Session object) Session.Clear (to clean up the contents of the Session object)

 

The Abandon

    the Abandon method removes all objects stored in the Session object and releases the source of these objects. If you do not explicitly call Abandon method, once the session times out, the server will remove these objects.

Syntax Session.Abandon

comments
    Abandon method is called, will sequentially delete the current Session object, but in all of the current page script commands are processed, the object will not actually be deleted. This means that when you call the Abandon, you can access the variables stored in the Session object on the current page, but not on subsequent Web pages.

    For example, in the following script, the third line to print out the value of Mary. This is because the servers have processed the Session object is not deleted before the script.

        <%
        Session.Abandon 
        the Session ( "MyName") = "Mary"
        Reponse.Write (the Session ( "MyName"))
        %>
 
    If you access the variable MyName on subsequent Web pages, you will find that it is empty. This is because when the page contains an example on the end of the process, MyName together with the front of the Session object is deleted.
    When the session is to give up and turn back the Web page, the server creates a new Session object. You can store variables and objects in the new Session object.

Example

    When the server processes this page, the following examples will release the session state.
        <% Session.Abandon%>

Clear

What Session.Abandon and Session.Clear different
    Session.Clear () is to put all the items in the Session object are deleted, Session objects inside Nothing. Session object but also retained.
    Session.Abandon () is the current Session object is deleted, the next time that a new Session.

The main difference is that:
    when using Session.Abandon, Session_End method calls (the InProc mode). Will inspire the next request arrives Session_Start method; and Session.Clear just erase all the data in the Session does not suspend the Session, and therefore does not call those methods.

 http://copperfield.iteye.com/blog/890018

session.invalidate () is the destruction associated with the user session, for example, forced some users close the browser, and track information about the user's session still exist, but the user has left.
Although the default browser session life cycle time of 30 minutes, but within 30 minutes another user also has access to a user's front page, users need to destroy the session.
session.removeAttribute () remove an attribute of the session.
Code log out of the pet store in spring example:
. Request.getSession () removeAttribute ( "the UserSession");
// log the user out, the session failed.
request.getSession () invalidate ().;

Guess you like

Origin www.cnblogs.com/shoshana-kong/p/11070027.html