Home > Article > Backend Development > Summary of cookies and sessions
Stored in the browser | The real file exists on the server | |
Security |
Low, easy to forge | More secure than cookies |
All types except resources |
Life cycle | Set through the third parameter |
Set through the php.ini file |
session.cookie_lifetime | session.gc_maxlifetime |
Valid path |
Settings setcookie('school','kefeng',time()+5,'/'); |
|
Depends on the effective path of the cookie can be configured in php.ini: | session.cookie_path=/||
The valid domain name |
is set by the fifth parameter string 'www.example.com' |
Depending on the valid domain name of the cookie can be configured in php.ini :
|
Read |
$_COOKIE[' '] $_SESSION[' '] |
Destroy
| setcookie(",", time()-1)
Four destruction methods: | 1. Destroy a certain unit:
unset($_session['school']); 2. Overall clearing: $_session = array(); |
session_unset(); Principle During the data interaction between the browser and the server, the server transmits the |
interaction) V is stored in the server , the data interacted between the browser and the server is K |
||
|