PHP exercises-session and value assignment of cookies

Source: Internet
Author: User
Tags set cookie

When assigning values to a SESSION, note that the first line of the PHP code in the value assignment page must be written session_start ();

To assign a value page:

<body><? PHP Session_Start (); // Be sure to remember to use the session when  each page should be added regardless of the value or the assignment page at the beginning to add: session_start ();//Session Control//http Protocol//http protocol called stateless protocol based on TCP protocol// Session features: 1 stored on the server; 2 each user generates a SESSION;3 has a default expiration time of about 15 minutes; 4session can store any type of data;//cookie features: 1 stored in the client ; 2 each user will generate a cookie;3 default no expiration time, but you can set the expiration time, 4 can only store string//session: Security But the server is too high,//cookie: Flexible insecure  //session use// 1, the page using SESSION must be opened in the first line of code sesssion$_session["UID"]= "Zhang San"; // Assignment//echo $_session[The use of the "UID"];//cookie Setcookie ("UID", "<br/> often"); // Assignment Method (set cookie)? ><a href= "Bi ji 2.php" >tiaozhuan</a></body>

Value page:

<body><? PHP Session_Start (); // regardless of how the value of the page (Assignment page) to add it, but also to write to the first line of PHP code; Echo $_session ["UID"]; Echo $_cookie ["UID"]; // Cookie Value ?></body>

PHP exercises-session and value assignment of cookies

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.