Summary of the cookie and session

Source: Internet
Author: User
Tags setcookie
Cookies Session
Storage location
stored in the browser

The real file exists on the server

, K exists in browser

Security
Low, easy to forge Higher security than cookies
Set up
Setcookie () function

Session_Start () after passing through PU

Pass function operation

Available Storage type
Scalar type: int, float, char, bool, NULL All types except Resources
Life cycle

Set by the third parameter

such as: Setcookie (' School ', ' XTU ', Time () +15);

Set by php.ini file

Session.cookie_lifetime

Session.gc_maxlifetime

Valid path

Set by the fourth parameter

Setcookie (' School ', ' Kefeng ', Time () +5, '/');

Depends on the valid path of the cookie

PHP.ini can be configured in:

session.cookie_path=/

Valid domain name

Set by the fifth parameter

String ' www.example.com '

Depending on the valid domain name of the cookie

PHP.ini can be configured in:

session.cookie_domain=

Read
$_cookie["] $_session["]
Destroyed

Setcookie (",", 0)

Setcookie (",", Time ()-1)

Four methods of Destruction:

1. Destroy a unit:

unset ($_session[' School ');

2. Overall Clearance:

$_session = Array ();

3, the use of the overall elimination of functions:

Session_unset ();

4, the boxes are not:

Session_destory ()

Principle

Between the browser and the server

The server in the data interaction

Data is transmitted via HTTP headers

To the browser next time Exchange

Over HTTP headers to the server

Store k in this process

(Number of browser-to-server

(interactive) v is stored on the server

In the process, the browser and the service

The data that the service interacts with is K.


The above describes the cookie and session summary, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.