Home > Backend Development > PHP Tutorial > Use URL to transfer SESSION information, url transfer session_PHP tutorial

Use URL to transfer SESSION information, url transfer session_PHP tutorial

WBOY
Release: 2016-07-13 09:46:37
Original
881 people have browsed it

Use URL to transmit SESSION information, url transmits session

In the study of PHP, we often use session, so today we will talk about session in detail. ;

1. Working mechanism of session:

When the session is opened, the server will save the session file in the server, and then save the session ID number in the browser to obtain the corresponding session information;

2. The following is the focus of the article: transferring session based on URL

If the session is transmitted according to 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 number on the link address of the website, so that we are not afraid of the user turning off the cookie!

(We take a simple user login as an example. When the user turns on cookies, it is transmitted by cookie, and when the user turns off cookies, it is transmitted by URL)

1. Create a user login page and add

after the action address of the form.

SID When the user turns on cookies, the output is empty
SID When the user closes the cookie, the current user session information is output. The specific format is session_name=session_id;

2. Create a page to determine whether the user is logged in;

When session_id() contains parameters, it means to use the id in the parameters as a reference to find the sessoin file. Note that session_id() must be in front of session_start()

3. Create a logout page

First clear the current user’s session data, and then delete the user’s session file

This whole small case of transmitting sessions based on URL is done! !

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1032053.htmlTechArticleUse URL to transmit SESSION information, URL transmits session. In learning PHP, session is what we often use. Then Today we will talk about the session in detail; 1. The working machine of the session...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template