Secure exit, clear Session or Cookie, sessioncookie

Source: Internet
Author: User
Tags exit in

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 ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.