PHP Session Code _php Tutorial

Source: Internet
Author: User
Tags php session

The session Code of PHP


The code only uses the SID to determine whether to use a cookie or session

 
  ;  The jump page cannot be a header    if (Isset ($_post[sub))) {    include conn.inc.php;    $sql =select ID from the users where Name= ' {$_post[name]} ' and password= '. MD5 ($_post[password]). ';    $result = $mysqli->query ($sql);    Save Data    if ($result->num_rows > 0) {    $row = $result->fetch_assoc ();        $_session[username]=$_post[name];    $_SESSION[UID]=$_POST[UID];    $_session[islogin5]=1;    Jump interface    echo ';    }    The Echo user name password is incorrect;    }? >
<title></title>
conn.inc.php

 
  comm.php

 
  index.php

 
  . $_session[username]. Hello! This is the homepage of the website;    Echo session_id ().;    echo you have the following permissions:;    $sql =select allow_1,allow_2,allow_3,allow_4 from users where id= ' {$_session[uid]} ';    $result = $mysqli->query ($sql);    $user = $result->fetch_assoc ();    if ($user [allow_1]) {        echo 111111111111;    }    if ($user [allow_2]) {        echo 222222222222;    }    if ($user [Allow_3]) {        echo 333333333333;    }    if ($user [Allow_4]) {        echo 444444444444;    }    ? >    > Second page    > third page    > exit

Test.php and test2.php are written on the same page as index.php.

 
  


http://www.bkjia.com/PHPjc/971084.html www.bkjia.com true http://www.bkjia.com/PHPjc/971084.html techarticle PHP Session Code code only to determine the use of a cookie or session through the SID;//The Jump page cannot be a header if (Isset ($_post[sub])) {include conn.inc.php; $sql = Select ID from Users ...

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