PHP session and cookie

Source: Internet
Author: User
<? PHP // ======================================================== ================================ cookie // $ cookievalue = 'cookievalue '; // two methods can be used to create a cookie // 1, // setcookie ("cookiename", $ cookievalue, time () + 600, "/T12/F1/F11 /"); // 2, // header ("Set-COOKIE: cookiename = $ cookievalue; expire = ". (Time () + 100 ). "; Path =/T12/F1/F11/"); // The first parameter is the cookie name. The setcookie method is only required for the cookie name, other optional parameters: // The second parameter is the cookie value // The validity period of the third cookie. Unit: Second // The fourth parameter path specifies the folder in which the page sets the cookie, by default, the folder where the current page is located // a cookie file can contain many cookie elements // if the path is not written, or an empty string, the cookie file of the current folder is generated by default, the cookie file name is "Name of the folder where the current access page is located +/" // path. To generate a cookie for a specified folder, the path must be "/+ absolute path of the folder" or "/+ absolute path of the folder + /", the maximum folder name is the folder name of the project. // the current page can access the values in the cookie files generated by the folder and all its parent folders, however, you cannot access the cookies generated by all subfolders in the folder. // echo $ _ cookie ["cookiename"]; // clear the cookie // setcookie ("cookiename ", ""); // or // setcookie ("cookiename", "", time ()-1 ); // ================================================ ================================== session // start session, run this method session_start () before outputting the page with $ _ session [] global variables; // set session $ _ session ['sessionname'] = "sessionvalue "; // use sessionecho $ _ session ['sessionname']; // destroy a session in three steps. session_destroy (); setcookie (session_name (), '', time () -3600); $ _ session = array ();

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.