Php session logout and login problems

Source: Internet
Author: User
Tags php session
This article mainly introduces the problem of session logout and login in php. if you need a friend, please refer to it and hope to help you in php, if the session is used to determine whether the user logs in, this can be done when the user exits:

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 ";
?>

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.