Click here to Skip to main content
16,004,727 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have one normal Login page ,1 Master Page as "ABC.Master" and 3

child pages as page 1, page 2, page 3. The page 1,page 2, page 3 are the child

pages of Master Page "ABC.Master".

After entering the Username and Password if I click on Login it moves to the Page

1 and from Page 1 if I click on some links it moves to Page 2. And from Page 2

if I click on the Browser Back button it should go back to Page 1 and then if I

click on Page 2 or Page 3 link then the Session should get expired.


Note: It should be purely like Banking website. i.e) On clicking the Browser back

button the Session has to get expired.

Repost of [This history][^]
Posted
Updated 30-Jan-14 2:08am
v3

use this for session clear

protected void Page_Init(object sender, EventArgs e)
       {
           Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));

           Response.Cache.SetCacheability(HttpCacheability.NoCache);

           Response.Cache.SetNoStore();
       }

Use this in page after
Session.Abandon();
 
Share this answer
 
Comments
MohammedRuman 30-Jan-14 4:13am    
Hi Samit. Thanks for ur reply.. As there is a same Master Page for page1,page2 and page 3 . so where to give session abandon () ; ? if i give session abandon in master page then it wont be able to move from login page to Master page itself .
As there is a same Master Page for page1,page2 and page 3 . so where to give session abandon () ; ? if i give session abandon in master page then it wont be able to move from login page to Master page itself .
 
Share this answer
 
on page load write

if(Session["YourKey"]!=null)
{
Session.Remove("YourKey");
}

hope it will work
 
Share this answer
 
Comments
MohammedRuman 30-Jan-14 4:13am    
Hi Salman Thanks for ur reply.. In the place of ["YourKey"] what to give ? As there is a no keycode for the browser back button. There is keycode for the keyboard keys not for the browser buttons
Salman622 30-Jan-14 4:19am    
Replace "YourKey" with the Session Key You want to Clear.
MohammedRuman 30-Jan-14 4:26am    
Salman..!! As i'm using Master page here . if i write this code in Master page load then it wont work because all the child pages are under master page. if i move forward from page 1 to page 2 also it has to go Masterpage and if i move back from page2 to page1 also it goes to back to Master page. How it will will know whether i'm clicking on other pages link or i clicked on the browser back button??

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