Where is the 1.SESSION information stored?
Copy Code code as follows:
<?php
Session_Start ();
$_session[' name ']= ' Marcofly ';
?>
Session default is saved to the C:\Windows\Temp directory, but by modifying the Session.save_path value in php.ini You can change the save path of the session.
such as: Session.save_path = "D:/wamp/tmp"
After executing the code, it will be in the D:/wamp/tmp directory, add a file named: sess_*** file, after opening, the contents are as follows: Name|s:8: "Marcofly";
File Content Explanation:
Name:key
S: Save type is a string
8: String length
Marcofly:value
What type of data can 2.SESSION hold?
As the previous example shows, sessions can hold strings, not only that, the session can also hold integers (int), Boolean (bool), arrays (array), and the session can save objects
Let's take a look at a simple example:
Copy Code code as follows:
<?php
Session_Start ();
$_session[' name ']= ' marcofly ';//String
$_session[' int ']= ' 10 ';//integral type
$_session[' bool ']=true;//boolean type
$_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 results are 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";}