Home  >  Article  >  Backend Development  >  Use session in php to determine whether the user is logged in and has permissions

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

WBOY
WBOYOriginal
2016-07-25 08:59:081655browse
  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.



Statement:
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