What is the usage of php $_session

coldplay.xixi
Release: 2023-03-07 15:28:02
Original
3009 people have browsed it

php $_session usage: 1. Initialize the session variable, the code is [session_start();]; 2. Write and read the session, the code is [$_SESSION['keyword']= "php" ;].

What is the usage of php $_session

php $_session usage:

When using PHP to apply a session, store the data in the session on the server , and then identify the client's information through the sessionID passed by the client, and extract the information.

Common operations of session in php: writing, reading, registering and deleting session.

Start of session

The function that marks the start of session use issession_start, and thesession_startfunction is used to initialize session variables. The syntax is as follows:

session_start();
Copy after login

The return value is TRUE.

Writing and reading of session

In PHP, the use of session is completed by calling and reading the predefined array$_SESSION.

In the website page, assign the$_SESSIONarray on the registration page, and read the$_SESSIONarray on other pages.

The session in the registration page, for example:

Copy after login

The session in other pages, for example:

Copy after login

Run in sequence, the result is:

php
Copy after login

Related free learning recommendations:php programming(video)

The above is the detailed content of What is the usage of php $_session. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!