Search
Left Quote    It is possible to store the mind with a million facts and still be entirely uneducated.
- Alec Bourne    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Session data not storing
  This user is online  Guest
  Subject: "Session data not storing" Posted: @ 9:54 pm on Feb 02 2006   
Unregistered
Hi, I've just gone through the login system tutorial. I'm able to register new users etc, and the login *seems* to work ok. Thing is, after i've logged in it 'forgets' that i've set the session variables.

In my login page, after the email/pass is verified I have (I switched it to just use email as the userid):

//set session variables
$_SESSION['logg ed_in'] = 1;
$_SESSION['emai l'] = $_POST['email'] ;
$_SESSION['pass word'] = $_POST['passwor d'];
session_write_c lose();

header("Lo cation: http://www.some url.com/subeng/ index.php"< img src=/forums/ima ges/smilies/win k.gif border=0>;

If I echo any of the session variables here instead of redirecting to the index they are displayed correctly (eg, logged in is 1, and the email is displayed).

My index.php includes my page_header.php . So the first thing that happens on redirect to index.php is page_header.php is called. While debugging I added these echos to page_header.php :

<?
ob_start();
session_start( );
require_once($_ SERVER['DOCUMEN T_ROOT'].'/sube ng/db_connect.p hp');

echo "..";
echo $_SESSION['logg ed_in'];
echo $_SESSION['emai l'];
echo "..";

Here, logged in is output as 0 and email is output as an empty string...

So while the session variables are being set correctly in login.php as soon as it redirects to my index.php those session variables are reset/lost.

Any ideas?

    Viewed: 6,438 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Session data not storing" Posted: @ 10:23 pm on Feb 02 2006    
Unregistered

If I add an addition session_start() ; before the session variables are set, it appears to be ok...

This doesn't make a lot of sense if the session has already been started though. Anyone able to explain it to me?



    Viewed: 6,431 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Session data not storing" Posted: @ 10:41 pm on Feb 02 2006    
Unregistered

do you use session_write_c lose(); in your page_header file? That would explain needing to use session_start() ; before declaring them in login.



    Viewed: 6,425 Times | Reply to This | To top
  This user is online  Guest
  Subject: "re: Session data not storing" Posted: @ 5:48 am on Feb 26 2006    
Unregistered

Hi, I have exactly the same problem, but i tried to add that extra session_start() .. but it didnt work for me..someone have an idea?



    Viewed: 6,380 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank