PHP Session Control Example analysis

Source: Internet
Author: User
Tags php session setcookie
This article mainly introduces the PHP session control, combined with an example of PHP for the cookie and session related operation skills, the need for friends can refer to the following

Specific as follows:

The test code for the cookie and session:

<?phpsession_start ();d efine (' u ', ' a ');d efine (' P ', ' 1 '), if (Isset ($_get[' R ')) && $_get[' R ']== 1) {unset ($_  cookie[' username ');  unset ($_cookie[' password '); unset ($_session[' Valid_login ');}  if (isset ($_post[' username ')) && isset ($_post[' password ')) {$username = $_post[' username '];  $password = $_post[' password ');    if ($username = = U && $password = = p) {$_session[' valid_login '] = 1;    Setcookie (' username ', $username);  Setcookie (' password ', $password);  } else {echo ' incorrect u or P '; }}?><?phpif (Isset ($_session[' Valid_login ')) {printf (' welcom,%s ', $_cookie[' username ');} else {?>< Form action= "" method= "post" > <input type= "text" name= "username" value= ""/> <input type= "password" name= "pa ssWOrd "value=" "/> <input type=" Submit "/></form><?php}?><br/><a href=" Cookie_ session.php "title=" ">refresh</a><br/><a href=" cookie_session.php?r=1 "title=" ">clear</a >

The above is the whole content of this article, I hope that everyone's study has helped.

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.