Home  >  Article  >  Backend Development  >  Summary of cookies and sessions

Summary of cookies and sessions

WBOY
WBOYOriginal
2016-08-08 09:25:451152browse

                                                                                                     

CookieStorage locationThe real file exists on the server, K exists in the browserSecurity More secure than cookies Scalar type : int, float, char, bool, nullLife cycleFor example: setcookie('school','XTU', time()+15);session.cookie_path=/setcookie(",", time()-1)1. Destroy a certain unit: (browser-to-server data The above has introduced a summary of cookies and sessions, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.
                                                                         
Stored in the browser

Low, easy to forge
All types except resources

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


session.cookie_domain=


Read

$_COOKIE[' ']

$_SESSION[' ']

Destroy


setcookie("," , 0)


Four destruction methods:

unset($_session['school']);

2. Overall clearing: $_session = array();

3. Use function to clear overall:
session_unset();

Principle

During the data interaction between the browser and the server, the server transmits the

data to the browser through the HTTP header for the next interaction. During the process
interaction) V is stored in the server
, the data interacted between the browser and the server
is K

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