Home  >  Article  >  Backend Development  >  In which file directory is SESSION information saved and what type of data can it be used to save_PHP Tutorial

In which file directory is SESSION information saved and what type of data can it be used to save_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:18:331749browse

1. Where is SESSION information stored?

Copy code The code is as follows:

session_start();
$ _SESSION['name']='marcofly';
?>

The session is saved to the c:windowstemp directory by default, but you can modify the session.save_path value in php.ini. Change the session save path.
For example: session.save_path = "d:/wamp/tmp"
After executing this code, a new file named: sess_*** will be added in the d:/wamp/tmp directory , after opening, the content is as follows: name|s:8:"marcofly";
Explanation of file content:
name: key
s: saving type is string
8: string length
marcofly: value
2. What type of data can SESSION save?
As shown in the previous example, session can save strings. Not only that, session can also save integer (int), Boolean (bool), array (array), and session can also save objects.
Let’s take a brief look at an example:
Copy the code The code is as follows:

session_start();
$_SESSION['name']='marcofly';//String
$_SESSION['int']='10';//Integer
$_SESSION[ 'bool']=True;//Boolean
$_SESSION['array']=array('name'=>'marcofly','age'=>'23');//Array
class test{
public $msg;
public function __construct(){
$this->msg="Hello World";
}
}
$obj=new test();
$_SESSION['obj']=$obj;//Object
?>

The result is as follows:
name|s:8:"marcofly ";
int|s:2:"10";
bool|b:1;
array|a:2:{s:4:"name";s:8:"marcofly"; s:3:"age";s:2:"23";}
obj|O:4:"test":1:{s:3:"msg";s:11:"Hello World"; }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325537.htmlTechArticle1. Where is the SESSION information stored? Copy the code as follows: ?php session_start(); $_SESSION['name']='marcofly'; ? The session is saved to the c:windowstemp directory by default, but by modifying...
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