can't get my session working

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Hi,


I m creating a session after a user login...
here an extract where I create it

Code:
if($found ==1){
							$Result = mysql_query("SELECT * FROM user WHERE user='$user'", $Link);
							$Row = mysql_fetch_array($Result);
							session_start();
							session_register('privileges');
							session_register('status');
							$HTTP_SESSION_VARS['privileges'] = $Row['privileges'];
							$HTTP_SESSION_VARS['status'] = $Row['status'];
							
		}

Then further in my page I have a link to some other page...normal you will say.. but then I dont understand...
In this new page I do session_start and when I do session_id();
I get the SID BUT when I do

Code:
print($HTTP_SESSION_VARS['status']);

There is nothing output.. Why my Array is empty???

Help please....

thanks
francois
 
as far as i know, the session_start() function should be the first line of your code meanning that it should be the first line of code prior to any output from the server including blank space.

it should be something like this.

<?php
session_start();
?>

<html>
your html stuff here or mix php stuff here
<?php

?>
</html>
 
Are u sure you are passsing SID

as follows
Code:
echo("<a href='somepage.php" . SID . "'>Somepage</a>");
 
cho@ said:
Hi,
Code:
if($found ==1){
							$Result = mysql_query("SELECT * FROM user WHERE user='$user'", $Link);
							$Row = mysql_fetch_array($Result);
							session_start();
							session_register('privileges');
							session_register('status');
							$HTTP_SESSION_VARS['privileges'] = $Row['privileges'];
							$HTTP_SESSION_VARS['status'] = $Row['status'];
							
		}


thanks
francois

If you are using php 4.1 or greater then you should be using superglobals i.e. $_SESSION[''] and not session_register.

check the stickies for some info on this.
 
Back
Top