Session control sessions, cookies

Source: Internet
Author: User
Tags php session

1<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> Untitled Document </title>6 78 9<body>Ten<?PHP One Session_Start();//before you store user information in a PHP session, you must first start the session.  A //Note: the Session_Start () function must precede the  - $_session["UID"]= "123";//Store session information and use it to store the user name later.  -  the $_session["Name"]= "Zhang San"; -  - Echo $_session["UID"]; - //first, session, second, cookie +  - Session 1, stored in server 2, can hold any type of data 3, has a default expiration time of 15 minutes 4, each login will store a copy +  A //Two, cookie 1, stored in the client 2, can only store string 3, the default permanent, you can set the expiration time 4, the customer can also save a copy at  - //session Usage - //1, can record the status of the logged-in person - //2, can be used to transfer values between pages - ///3, can prevent users from skipping login - //4, login user name, shopping cart, process in  -  to?> +<form action= "hhcl.php" method= "POST" > -<div> Username: <input type= "text" name= "AAAA"/></div> the  *<div> Password: <input type= "text" name= "pwd"/></div> $<div><input type= "Submit" value= "Login"/></div>Panax Notoginseng</form> -</body> the +  A  the<?PHP + Session_Start(); -  $  $ $uid=$_post["AAAA"]; -  -  the //Cookie Storage Information - //setcookie ("UID", $uid);Wuyi Header("location:main.php"); the  -<title> Untitled Document </title> Wu -  About<body> $<?PHP - Session_Start(); - if(!Empty($_session["UID"])) - { A      +}Else the { -     Header($_session["UID"]); $ } the  the Echo $_session["UID"]; the?> the  -</body> in

123

Session control sessions, 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.