Artur Peniche
Artur Peniche

Reputation: 479

Successful Logoff using Session c#

I'm trying to implement a log off system on my project. I've the following:

mypage.cs

 protected void imgBtnLogOff_click( object sender, ImageClickEventArgs e )
        {
            Session.Clear();
            Session.RemoveAll();
            Session.Abandon();
            Response.Redirect( "./Logout.aspx" );
        }

Logout.aspx

<h2>Thanks and come again!</h2>
        <asp:LinkButton runat="server" ID="lbLogIn" Text=" click to log in!" OnClick="login_in"></asp:LinkButton>
    </div>

Logout.aspx.cs

protected void login_in( object sender, EventArgs e )
        {

             Response.Redirect( "mypage.aspx" );
        }

Thing is, since it has no session,every time I enter the page in the first time this prompts for user and pw input. But using this logout method it redirects successfully but with the old user, without asking for information.

Any thoughts of richer ideas?

Upvotes: 0

Views: 82

Answers (1)

Peter Toth
Peter Toth

Reputation: 21

An advice I got back then is to redirect the user to a 'logout' page in the code have - Session.RemoveAll(); and redirect to the login page.

Upvotes: 2

Related Questions