PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have recently tried to create an administration session, everything seems to work including login except when I redirect to a session holding page for some reason the sessions do not maintain state and I'm driving myself crazy trying to find out why. This is what I am using to try and get the sessions to work, according to the tutorial nothing should be going wrong!!!!
Well one thing to watch out for is that header() won't propagate the session if the user denied the cookie and is using GET style sessionID propagation. The work around I use:
function localRedirect($url)
{
GLOBAL $HTTP_COOKIE_VARS;
if (isset($HTTP_COOKIE_VARSї"PHPSESSID"]))
header($url);
else
header($url . "?" .SID);
}
Use this function exactly like header() but for redirects within your site. Use header for links out of your site to avoid spilling your identifiers.
This is a very simple function and won't work if you regularly use GET style urls in your site. If you do you'll have to slightly modify the else portion to figure out if an ampersand or a '?' is needed.