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