Jump to content

Sessions


damdempsel

Recommended Posts

I have a log in script where a session is set with the persons username and there is also another session set if they are an admin. The admin session seems to be having a bit of trouble. On my admin page, if there is no admin session it will log their IP and send them to the index page. There is also a list of links that only admins can see. When I sign in with an admin account, I am able to see the links but I can't go to the admin pages. I use pretty much the same codes to display the links and to allow access to the pages.

 

The code I use for setting the admin session is:

$_SESSION['admin'] = $username; 

The code I use for the links is:

if ($_SESSION['admin']) {}

^-- I removed bits of code from this. This is just the main part of it.

The code for the admin page is:

if (!$_SESSION['admin']) { header("location: index.html");}

^-- This is just the main part of the code.

 

Setting the session works fine, and displaying the links is fine. The only problem is the admin page. Does anyone see something wrong with that part of the code?

Link to comment
https://forums.phpfreaks.com/topic/185804-sessions/
Share on other sites

Well, if you are unable to view the admin pages using

 

if (!$_SESSION['admin']) { header("location: index.html");}

 

I would suggest try var_dumping($_SESSION['admin']) and tell us what the value is.

My first guess is that it is getting redefined somewhere else as "" or unset. 

Link to comment
https://forums.phpfreaks.com/topic/185804-sessions/#findComment-981092
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.