Jump to content

isset


pranshu82202

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.