Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

session variables not working php

session variables not working php  using -'php,session,session-variables'

Here are the code of my login page where the login script checks for the authenticity of the user and then redirects to inbox page using header function.


// Some query processing on database    

if(($id_user_fetched<=$id_max_fetched) && ($id_user_fetched!=0)){
$_SESSION['loggedIn'] = 'yes';
    //echo 'Login Successful';
        echo 'Invalid Login';
        echo'<br /> <a href="index.html">Click here to try again</a>';
    echo mysqli_error("Login Credentials Incorrect!");

The inbox.php page looks like this:

echo 'SESSION ='.$_SESSION['loggedIn'];
if($_SESSION['loggedIn'] != 'yes'){
echo $message = 'you must log in to see this page.';


Now with the above code, the inbox.php always shows the output:
 SESSION=you must log in to see this page.
Which means that either the session variable is not being setup or the inbox.php is unable to retrieve the session variable. Where am i going wrong?

asked Sep 14, 2015 by MickeyBearde
0 votes

Related Hot Questions

Government Jobs Opening