Dynamic session variable requires refresh

Hello everyone and thanks in advance for the help. I am working on a permission system for a site I am creating that will be used to restrict access to various areas of the site. I have a table with all the permission that is linked to a group that the user is a member of. I then use a query to get a list of the permission ids the user is part of and put those into the session array. I used a basic login script I found online I planned on modifying to add my own features and to make more secure.

Originally it had just a member id and member name variable in the session array saved in the login script which are both working fine after login. I am using a dynamic variable to set one session variable for each permission with the id being the changing part in the variable name. The problem I found is that the new variables are not being set. When i removed the redirect from my login script so I could check the problem I found that the temp variable, which is also set before it saves to the session array, is blank as well. If I hit refresh on my browser the new variables become set and all is well. My login script is available in my pastebin (http://pastebin.com/u/eagled2).

When i removed the redirect from my login script so I could check the problem I found that the temp variable, which is also set before it saves to the session array, is blank as well. If I hit refresh on my browser the new variables become set and all is well.

Try to modify your code as shown below:

[php]//Check User Permissions
IF (isset($_SESSION[‘SESS_PERM1’])) {
session_write_close();
header(“Location:httest.php”);
header(“Status: 303”);
exit;
}[/php]

If this not helped, as an option you can save your variable to cookie.

Sponsor our Newsletter | Privacy Policy | Terms of Service