简体   繁体   中英

how to make sure not to read another page only after loging in

here you may find my verification code with this code i want not to redirect to another page only after logging in how shall i do ?

<?php
if (isset($_SESSION['login']))
    session_start();

if (!isset($_SESSION['login']) || $_SESSION['login'] != 'ok') {
    header("location:login.php");
    exit();
}

?>

i would use isset combined with empty just for extra precaution

session_start();
if(isset($_SESSION['login']) && !empty($_SESSION['login'])) {
   header("location:user.php");
}
else {
  header("location:login_form.php");
}

don't use exit(); just redirect

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM