I'm sorry guys -- after two hours of looking and commenting out and so on, I found one tiny include that was referencing a redirected domain. Somehow this threw everything else off. I'm still not sure why, but by fixing that file to the new domain I was able to fix it. Again, thanks for your help and time in replying to me!
I'm fairly familiar with sessions in PHP, yet I can't tell why these session variables are not sticking on this login system I have. When I log in, I get successfully sent to the index page, but any pages therein I get kicked back to the login page, and also when I reload the index page. I have echoed the session variable $_SESSION['login'] on the index page to make sure its value has accurately been carried over, and it's is there..
... code removed
Why are you destroying the session during login? This is probably a reason.
session_start();
session_unregister('login');
session_write_close();
session_start();
session_destroy();
You probably might just call session_start() and clear 'login' session value:
<?
$ERRBG="";
$ERRMSG="";
session_start();
$_SESSION['login'] = null;
require_once("db/mysql_connect.php");
.......
My wild guess but usually a problem I always encounter in Apache under Linux when dealing with sessions.
Check session.save_path
in php.ini. If there's a path there and doesn't exist in your system, create it e.g. session.save_path = "/var/lib/php/session"
. I'm guessing PHP cannot create session files and thus session won't persist across pages. Give the folder a write permission too, try 0777
(but it's not the best permission as it allows all users). HTH!
Use session_start() only once in the php page at the starting
Do not use session_destroy(). If you want to remove session variable, use unset
function. In case if you want to remove all the variables use session_unset
function
Use session_destroy() as the logout operation
Please do this step :
<?php
just once .I think session start in your test-index but not in your other page
report result to me !