Blogger Information
Blog 30
fans 0
comment 0
visits 22397
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
8.31cook&session
归宿的博客
Original
524 people have browsed it
  1. cookie实现用户登录与验证

//判断用户是否登录:
if(isset($_COOKIE['id']) && basename($_SERVER['PHP_SELF']) != 'logout.php'){
    echo '<a href="logout.php">退出</a>';
}else{
    echo '<a href="login.php">登录</a>';
}


    2.session实现用户登录与验证

//判断用户是否登录:
session_start();//开启会话
if(isset($_SESSION['id']) && basename($_SERVER['PHP_SELF']) != 'logout.php'){
    echo '<a href="logout.php">退出</a>';
}else{
    echo '<a href="login.php">登录</a>';
}

    3.cookie与session会话机制的优缺点分析:

  1).cookie是存在用户本地的,没有session安全.

  2).session是存在服务器端的

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post