This has really been confusing me. I have my php script set up to take the user ID out of the database, and put it into a session variable, however.. This will only work as long as I navigate through one directory.
i.e user/index.php --> user/account.php holds the info, but user/index.php --> account/index.php gives me this error:
"Notice: Undefined index: user_id in (host root dir)/account/index.php on line 14"
Now for the code..
Function that sets the info for $_SESSION['user_id']:
function getId()
}
$email = $_POST['txtEmail'];
$password = $_POST['txtPassword'];
$sql = "SELECT login_id
FROM tbl_login
WHERE login_password = ('$password') AND login_email = ('$email')";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$_SESSION['user_id'] = $row['login_id'];
{
user/library/functions.php - holds the getId() function.
user/login.php - calls the function and registers the session.
user/account/index.php - tries to get the session info but fails (yes I put session_start() before I called the info) "Notice: Undefined index: user_id in (host root dir)/account/index.php on line 14"
The wierdest thing is about this, is that when I go back to user/login.php to check if the session is registered or not, it says that it is. But then I go back to account.php and of course its not.. stays this way till I unregister.
like I said.. if I keep in in the same directory everything runs fine. As far as I understand sessions are supposed to retain data no matter which directory you are on as long as staying in the root dir (or untill you unregister/close browser).
Anything helps. My main goal is to be able to hold this login_id info from 'blahblah/var.php' to 'blahblah/anything/var.php' Thank you very much in advance.