Home > Backend Development > PHP Tutorial > Using URL to transfer SESSION information instance

Using URL to transfer SESSION information instance

*文
Release: 2023-03-18 17:58:01
Original
1418 people have browsed it

This article mainly introduces relevant information on using URL to transmit SESSION information. Friends in need can refer to it. I hope it will be helpful to everyone.

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

1. The working mechanism of the 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: Based on URL Transmitting session

If you transmit the session 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 simple user login as an example. When the user turns on the cookie, it is transmitted by cookie, and when the cookie is turned off, 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, output empty
SID When the user closes the cookie, the current user session information is output. The specific format Yes session_name=session_id;

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

When session_id() contains parameters, it refers to the id in the parameters. Find the sessoin file for reference. Note that session_id() must be in front of session_start()

3. Create a logout page

First, set the session data of the current user Clear and then delete the user's session file

The whole small case of session transmission based on URL is done! !

Related recommendations:

Destruction of PHP session variables

Ajax and PHP session creation shopping cart example detailed explanation

php session validity period

The above is the detailed content of Using URL to transfer SESSION information instance. For more information, please follow other related articles on the PHP Chinese website!

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