petre ricardo

petre ricardo

  • NA
  • 194
  • 0

Use of session objects and cookies!

Oct 25 2009 1:58 PM

Hi,
I have written teh simple login page that directs teh user to his home page if the login is valid and when the user clicks log off, it directs the user to the login page.
The issue lies on this:
Onces teh user logs off he cannot go back to his home page using the browser back button.
I have used two step sfor this:
1. In the user's home page once the user has clicked log off, i have set URL path to loginpage, and in login page's Load() event i have cleared on the session objects's stored user name and password.
2. In the Load() of the user's home page i have writteon the following code:
 

if
(this.IsPostBack == false)
{
   if (Session.Count == 0)
   {        //this will directs the user back to the login page if the user clicks
 
        //back button at the login page.
         Page.Response.Redirect("LoginPage.aspx");

   }   
   else
   {
         lblFirst.Text = Session[
"FirstName"].ToString();
         lblLast.Text = Session[
"LastName"].ToString();
   }
}

 
How good is my technique or should i stickly use cookies and session IDs? I need to know Pros and Cons of my technique :)
TY
 

Answers (1)