Home  >  Article  >  Backend Development  >  Introduction to php Session

Introduction to php Session

怪我咯
怪我咯Original
2017-07-16 11:13:341811browse

Introduction to php Session

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[&#39;views&#39;]=1;
?> 
<html>
<body>

<?php
//retrieve session data
echo "Pageviews=". $_SESSION[&#39;views&#39;];
?>

</body>
</html>
 [html]
终结 Session
unset() 函数用于释放指定的 session 变量:
[code]
<?php
unset($_SESSION[&#39;views&#39;]);
?>

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!

Statement:
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