how to abandon session after browser close

Posted by Shanky11 under ASP.NET on 9/21/2013 | Points: 10 | Views : 1961 | Status : [Member] | Replies : 6
When the Abandon method is called, the current Session object is queued for deletion but is not actually deleted until all of the script commands on the current page have been processed. This means that you can access variables stored in the Session object on the same page as the call to the Abandon method but not in any subsequent Web pages.



what does the line written in b tag signify
Please give the details description of that lline i.e not actually deleted until all of the script commands on the current page have been processed




Responses

Posted by: Bandi on: 9/21/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
for your scenario use Session.cleae() to just clear values in counter

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/21/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
refer these links once
http://forums.asp.net/t/1116238.aspx
http://stackoverflow.com/questions/13247848/is-this-possible-to-clear-the-session-whenever-browser-closed-in-asp-net


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/21/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://www.codeproject.com/Tips/154801/How-to-end-user-session-when-browser-closed

http://www.codeproject.com/Questions/217449/clear-session-while-browser-is-closed-using-asp-ne

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nismeh on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
public class BasePage : Page
{

protected string mySessionId;

private CurrentUser _currentUser;
public CurrentUser _CurrentUser
{
get { return ((CurrentUser)HttpContext.Current.Session["myCurrentUser"]); }
set { _currentUser = value; }
}


protected override void OnLoad(EventArgs e)
{

if (Session["myCurrentUser"] != null)
{
if (_CurrentUser.ProUser)
{

mySessionId = Session.SessionID; // it means New Session

}

if (!mySessionId.IsNullOrDefault() && mySessionId != Session.SessionID)
{
Session.Abandon(); //Abandon current session and start new one

}
}


}

}

IT KNOWLEDGE IS APPLIED KNOWLEDGE
So Just Do It

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 9/23/2013 [Member] Starter | Points: 25

Up
0
Down
Session.Clear() will clear all session objects.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 9/23/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

this is not working can you post zip format

i write the code and click close button in chrome

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response