Home Backend Development PHP Tutorial The concept of Session in PHP_PHP Tutorial

The concept of Session in PHP_PHP Tutorial

Jul 21, 2016 pm 04:05 PM
php session generally Chinese What Woolen cloth difficulty yes concept Compare of

What is Session? It is difficult to directly translate Session into Chinese, and it is generally translated into time domain. In computer terminology, Session refers to the time interval between an end user communicating with an interactive system, usually referring to the time elapsed between registering to enter the system and logging out of the system. Specifically, Session in the Web refers to the time that elapses from entering the website to closing the browser when a user browses a website, which is also the time spent by the user browsing the website. Therefore, we can see from the above definition that Session is actually a specific time concept.
It should be noted that the concept of a Session needs to include a specific client, a specific server and uninterrupted operation time. The Session in which user A establishes a connection with server C and the Sessions in which user B establishes a connection with server C are two different Sessions.
So what is the solution for Session? We know that users often need to browse many web pages when visiting a website. For a website built with PHP, users need to execute many PHP scripts during their visit. However, due to the characteristics of the HTTP protocol itself, users need to re-establish a connection with the Web server every time they execute a PHP script. And due to the characteristics of stateless memory, this connection cannot obtain the status of the last connection. In this way, the user assigns a value to a variable in one PHP script, but cannot get the value of the variable in another PHP script. For example, the user sets $user="wind" in the PHP script responsible for logging in, but cannot obtain the value of "wind" by calling $user in another PHP script. That is, global variables cannot be set in PHP. The variables defined in each PHP script are local variables that are only valid within this script.
The Session solution is to provide a method to define global variables in PHP scripts, so that this global variable is valid for all PHP scripts in the same Session. As we mentioned above, Session is not a simple time concept. A Session also includes specific users and servers. Therefore, in more detail, the scope of global variables defined in a Session refers to all PHP accessed by the user corresponding to this Session.
For example, user A defines a global variable $user="wind" through Session, and user B defines a global variable $user="jane" through Session. Then in the PHP script accessed by user A, the value of $user is wind.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315797.htmlTechArticleWhat is Session? It is difficult to directly translate Session into Chinese, and it is generally translated into time domain. In computer terminology, Session refers to when an end user communicates with an interactive system...
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles