I think you want the session_start() and session_register() calls at the top
of the script, not buried in your if() statements.
--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: "Karl J. Stubsjoen" <[EMAIL PROTECTED]>
Newsgroups: php.general
Sent: Thursday, February 15, 2001 11:36 AM
Subject: [PHP] Help with session
> I have 2 functions on my page, RegisterUser, IsValidUser.
> RegisterUser looks in the querystring to see if you've passed a certain
key
> & value. If you have it populates a session variable called "ValidUser"
> with a 1.
> All that IsValidUser does, is check to see if the session variable
> "ValidUser" is a 1 or not.
>
> It doesn't work.
> RegisterUser (which sets session variables) is taking place before headers
> are written to the browser. I'm not gettin errors, but the problem is
that
> ValidUser isn't able to read the session variable for some reason.
>
> Any Ideas?
>
> Here is the code for these 2 functions:
>
> function IsValidUser()
> {
> global $HTTP_SESSION_VARS;
>
> $reslt = 0;
>
> if (isset($HTTP_SESSION_VARS["ValidUser"]))
> {
> if ($HTTP_SESSION_VARS["ValidUser"] == "1")
> $reslt = 1;
> }
> print("ValidUser? " . $HTTP_SESSION_VARS["ValidUser"] . "<br>");
>
> return($reslt);
> }
>
>
> function RegisterUser()
> {
> global $HTTP_SESSION_VARS;
> global $HTTP_GET_VARS;
> $reslt = 0;
>
> if (isset($HTTP_SESSION_VARS["ValidUser"]))
> {
> if ($HTTP_SESSION_VARS["ValidUser"] == 1)
> {
> $reslt = 1;
> }
> }
>
> if ($reslt=0);
> {
>
> $Val_User = $HTTP_GET_VARS["fis"];
>
> if ($Val_User == "1")
> {
> $reslt = 1;
> if (!isset($HTTP_SESSION_VARS["ValidUser"]))
> {
> session_start();
> session_register("ValidUser");
> $HTTP_SESSION_VARS["ValidUser"] = 1;
> }
> else
> {
> $HTTP_SESSION_VARS["ValidUser"] = 1;
> }
> }
> else
> {
> $reslt = 0;
> }
> }
> return($reslt);
> }
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]