Jump to content

[SOLVED] Having trouble setting session


derekbelcher

Recommended Posts

Hello.  I am having trouble getting my session to work in php.  I have a login page that sends the username and password to a "checklogin" page.  Here I have code that sets the session if the right credentials are submitted:

 

if($count==1){

 

// Register $myusername, $mypassword and redirect

 

$_SESSION['myusername']=$myusername;

$_SESSION['mypassword']=$mypassword;

 

 

// Redirect to appropriate admin page

 

while($row=mysql_fetch_assoc($result)){

$adminpage=$row['admin_redirect'];

}

 

header("location:$adminpage");

}

else {

 

header("location:adminLoginError.php");

}

 

On the successful login page I have this code:

 

<?php

if(!isset($_SESSION['myusername'])) {

header("location:adminLogin.php");

}

?>

 

For some reason I am not getting to the success page.  When you enter the username and password you just get a new login page.  I am assuming that it is not recognizing a registered Session.  If I remove the (!) from before isset, then it works fine, but I know that it is not checking the username and password.  Help please!

 

Link to comment
https://forums.phpfreaks.com/topic/155404-solved-having-trouble-setting-session/
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.