Click to See Complete Forum and Search --> : seestion error Help need??


alpesh_vaghasiy
02-15-2007, 02:00 PM
hello sir,
i am student of sarvajanik college of eng. & technology surat.
i am creating a website in VB.NET2003. i have already created the entire project but i am facing one problem in that.
i have created the logout page in my project.I am using session in my project. In logout page i am expiring the session. The code for that is as follows

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Session.Contents.Item("userid") = ""
Session.Contents.Remove("userid")
Session.Abandon()
End Sub

In this coding i am making userid blank.

Now from any other page in my project when i click logout i am able to logout. In all the other page except logout page i have written following code in page load event

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session.Contents.Item("userid") = "" Then
Response.Redirect("login.aspx")
End If
End Sub

In this i am checking if the userid is blank then i am redirecting it to my login page.now suppose i have logout.so i am in logout page now.
Now the problem is that even though i have expire the session, when i click the back button in browser i am able to go back which should not happen. If am clicking any button on my page then the pageload event coding is called and i am redireted to my login page.
But i need that once i logout i should not be able to go back. By clicking back i should be redirected to my login page.
how can i do this. (what i mean to say is that consider the case of yahoo mail. when i login i am inside my mailbox. now suppose i logout then i goes to logout page. now even if i click back button in browser then i am redirected to login page and not my mailbox. This is what i want, but i don't know how to do so)
please reply me as soon as possible
hoping for a favourable reply
your truly

lmf232s
02-15-2007, 05:06 PM
the problem is that when you press the back button the browser serves up a cached copy of the page and does not rerun the page.

Depending on your needs you can disable this feature so that a page is not cahced and forces the browser to reload the page. It when then hit your code checking for sessions and then do the redirect back to the login page.

Here is a line of code that i have on my site but im also running .net 2.0 so im not sure if this is available in .net 1.0.

Response.Cache.SetCacheability(HttpCacheability.NoCache)