PHP Chapter II

Source: Internet
Author: User

Cookie data is recorded in the browser, session data is recorded on the server.

Set cookies


<? PHP /*  *//cookies are stored in Requestheader//Set cookies for multiple page transfer data Setcookie(' Name ', ' Big head Son '); // jump to another page, pass the value by Get method Header ("Location:a.php?title=superman");


<? PHP /*  */echo$_cookie[' name ']; Echo ' <br/> '. $_get [' title '];

Set session

<? PHP /*  */ / use SESSION multiple pages to access data $_session[' theme '] = ' Jay Chou '; // the server clears the session Session_destroy (); Header (' location:a.php ');


<?PHP/** * Created by Phpstorm. * User:forr * date:15/9/16 * Time: PM 11:28*/Session_Start();$f=Empty($_session[' Theme ']);if($f){    Echo $_session[' Theme ']; Echo session_id();}Else{    Echo' 404 Not Found ';}

PHP Chapter II

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