What is Session
Session is difficult to translate directly into Chinese, and 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 from registering to enter the system to logging out exiting 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.
Before you store user information in a PHP session, you must first start the session.
Notes: session_start() Function must be placed before the label:
<?php session_start(); ?> <html> <body> </body> </html>
Storage Session Variables
<?php session_start(); // store session data $_SESSION['views']=1; ?> <html> <body> <?php //retrieve session data echo "Pageviews=". $_SESSION['views']; ?> </body> </html> [html] 终结 Session unset() 函数用于释放指定的 session 变量: [code] <?php unset($_SESSION['views']); ?>
Related topic recommendations: php session (including pictures, texts, videos, cases)
The above is the detailed content of Introduction to php Session. For more information, please follow other related articles on the PHP Chinese website!