Use URL to transmit SESSION information and url to transmit session information

Source: Internet
Author: User

Use URL to transmit SESSION information and url to transmit session information

In php learning, sessions are often used. Today we will talk about sessions in detail;

I. session working mechanism:

When the session is enabled, the server saves the session file on the server, and then saves the session ID in the browser to obtain the corresponding session information;

II. The following is the focus of the article: transmitting sessions based on URLs

If the session is transmitted using the basic session method, the cookie in the user's browser will be used. Once the user closes the cookie, the session will not work! So next we will put the session ID on the link address of the website, so that users are not afraid to close the cookie!

(We use simple user logon as an example. When a user enables a cookie, the cookie is transmitted as a cookie. When the cookie is disabled, the cookie is transmitted as a url)

1. Create a user logon page and add

SID: When the cookie is enabled, the output is empty.
SID: When the cookie is disabled, the current user's session information is output. The specific format is session_name = session_id;

2. Create a logon page to determine whether a user is logged on;

Session_id () indicates that the sessoin file is found based on the id in the parameter. Note that session_id () must be before session_start ().

3. Create an exit logon page

First, clear the session data of the current user, and then delete the session file of the current user.

This is a small case of url-based session transmission !!

The above is all the content of this article. I hope you will like it.

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.