pranshu82202 Posted August 26, 2011 Share Posted August 26, 2011 i Have two page login.php and verify.php In login.php user is entering Username and Password and in the action of the form i am writing verify.php. If verification is a success then i will start a session() session_start(); $_SESSION['ls']="loggedin"; // ls stands for login status $_SESSION['id']=$row['id']; $_SESSION['user_name']=$row['user_name']; $_SESSION['email']=$row['email']; header('location : members.php'); die (" "); and will redirect them to members.php .... Everything is working fine... But in login.php i have written a code on the top... <?php if(isset($_SESSION['ls']) && isset($_SESSION['id']) && isset($_SESSION['user_name']) && isset($_SESSION['email']) ) { header('location:members.php'); die(" "); } ?> I want if a session is started and if user will access login.php they will automatically go to members.php But this script is not working... Iam not getting whats the problem... also i m not getting any error login.php or anything CODE WRITTEN ON THE TOP OF members.php IS : <?php session_start(); if(@$_SESSION['ls']!=="loggedin" ) // Checks if the person has done stage one (Registration.php) { header('Location: login.php'); //If they haven't done it, it sends them back. die (" "); } ?> Link to comment https://forums.phpfreaks.com/topic/245749-isset/ Share on other sites More sharing options...
WebStyles Posted August 26, 2011 Share Posted August 26, 2011 to access any session variable, you must have session_start() at the top of the file, so login.php should be: <?php session_start(); if(isset($_SESSION['ls']) && isset($_SESSION['id']) && isset($_SESSION['user_name']) && isset($_SESSION['email']) ) { header('location:members.php'); die(" "); } ?> in this case, you need to remove the other session_start() you have in login, or it will throw a warning. Link to comment https://forums.phpfreaks.com/topic/245749-isset/#findComment-1262199 Share on other sites More sharing options...
pranshu82202 Posted August 26, 2011 Author Share Posted August 26, 2011 Thanx webstyles... Link to comment https://forums.phpfreaks.com/topic/245749-isset/#findComment-1262203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.