Use session in php to determine whether the user is logged in and has permissions

WBOY
Release: 2016-07-25 08:59:08
Original
1548 people have browsed it
  1. Username:
  2. Password: < br>
Copy code

2. PHP code for verification

  1. session_start();

  2. $_SESSION["user"]=$_POST[user];
  3. $_SESSION["password"]=$_POST[pwd];
  4. if ($_SESSION[user]==""){
  5. echo "";
  6. }

  7. if($_SESSION["user"]=="admin"){

  8. echo "Current login: System Administrator
    User Management";
  9. }else{
  10. echo"Current login: ".$_SESSION[user]."
    < a href='album.php'>My Album";
  11. }
  12. ?>

Copy the code

It’s simple, for those who are new to session in php , this small example, I hope it will be helpful to everyone.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!