Home > Backend Development > PHP Tutorial > Transmit session information based on website address URL, website address urlsession_PHP tutorial

Transmit session information based on website address URL, website address urlsession_PHP tutorial

WBOY
Release: 2016-07-13 09:51:47
Original
858 people have browsed it

Transfer session information based on website address URL, website address urlsession

In the study of php, sessions are what we often use, so today we will Let’s talk about session in conversation in detail;

1. The 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: Transmitting session based on URL
If the session is transmitted according to the basic session method, then the cookie in the user's browser will be used. Once the user closes the cookie, then Session doesn’t work anymore! 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 simple user login as an example, When the user turns on cookies, it is transmitted by cookie, 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 the cookie, the output is empty
SID When the user turns off 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 that the id in the parameter is used 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 session transmission based on URL is done! !

This article is original to Wang Yelou’s personal blog. If you want to reprint, please indicate the source: Wang Yelou’s personal blog http://www.ly89.cn/detail/28.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1012253.htmlTechArticleTransfer session information based on website address URL, website address urlsession In the study of PHP, session is what we often use , then today we will talk about the session in detail; 1...
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