Secure exit, clear Session or Cookie, sessioncookie
Overview:
Click exit in the website. If you only redirect to the logon/exit page, enter a page address such as the homepage in the address bar of the browser, and you will find that you can access it without logging on. This so-called exit is not safe.
So how can we exit safely?
That is, click to exit and clear the corresponding Session or Cookie.
Clear the Session code:
Session.Clear();Session.Abandon();
Below we will summarize several methods for implementing security exit.:
1). Exit with server controls such as Linkbutton and Button.
This method is best handled: simply write the code to clear the Session or Cookie in the event corresponding to the server control.
2) Use HTML tags such as <a> logout </a> to exit
The special mark <a> </a> can be implemented as follows: <a href = "logout. aspx "> logout </a>, In the logout. in the Page_Load event of aspx, write the code to clear the Session or Cookie.
For HTML tags such as <a> </a>, you can use Js-Ajax or jQuery-Ajax in the corresponding client events marked by HTML (. to clear the Session or Cookie.
For HTML tags such as <a> </a>, you can also add a server control such as a Button on the current page, use div to include it, and hide it (note: hidden and invisible. The server attribute Visible = False can only be used to set the display: none; of the div.) Compile the code to clear the Session or Cookie in the server event Cilck of the Button; then, you can use Js or jQuery to call the Click Event of the Button control in the corresponding client event marked in HTML (set the Button to hide by using the Server property Visible = False, js or jQuery calls the Button control's Click event will be invalid ).