Session logout in php _ PHP Tutorial

Source: Internet
Author: User
Php session logout and login issues. In php, if the session is used to determine whether the user logs on to the server and exits, it can be like this: session_start (); session_destroy (); the session indicates that it has ended. The next statement should be written in php. if the session is used to determine whether the user logs in or out, this can be done:

Session_start ();
Session_destroy ();

The session is ended. In the next sentence, JavaScript should be written to redirect the page.

Script alert ("logged out! "); Location. href =" login. php "; script

If it is a framework page, do not use location directly. Because this will jump in a small frame page, the intention must be that the entire framework should jump over. Therefore, "parent." must be added before location .".

The entire process is as follows (for the Framework page only ):

The code is as follows:


Session_start ();
Session_destroy ();
// To redirect the entire framework page to the login page
Echo "script" alert ('logged out '); parent. location. href = 'login. php'; script ";
?>

Sessions session_start (); session_destroy (); the session is over. The next sentence should be written...

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.