Re: [PHP] Problem grabbing value of session

2002-04-16 Thread Jeff Lewis

I've decided to use the _SESSION method instead and it works just fine :)
So...thanks for suggesting that method, as it does look neater in the code
as well.

Jeff
- Original Message -
From: "Erik Price" <[EMAIL PROTECTED]>
To: "Jeff Lewis" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, April 16, 2002 2:42 PM
Subject: Re: [PHP] Problem grabbing value of session


>
> On Tuesday, April 16, 2002, at 02:40  PM, Jeff Lewis wrote:
>
> > Right after I call those I try a is_registered and it showed that these
> > registered correctly.  I removed that code and added a call to another
> > function: redirectinternal();
>
> You can avoid the whole "session_register()" business if you simply
> refer to these variables as $_SESSION['valid_user'] and
> $_SESSION['privs'] -- after all, that's what they are, simply session
> variables.  By using this convention, you clarify exactly what kind of
> variables they are each time you write them, which is good for
> legibility later in the future.  Also, you don't need to declare them as
> global in your redirectinternal() function, since any $_* variable is
> considered global at all times.
>
> > That function is below:
> >
> > function redirectinternal () {
> >  global $valid_user,$privs;
> >
> >  echo "Login good!";
> >  echo "".$valid_user." - ".$privs.$temp;
> >
> > }
> >
> > Now, I can't seem to get those values to print to the screen.  I added a
> > session_start before the echo and I just can't get my values out...what
> > am I
> > missing?
>
> You'll have to post the context of this function (how it is called in
> the script) for an answer to this question.
>
>
> Erik
>
>
>
>
>
> 
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Problem grabbing value of session

2002-04-16 Thread Kevin Stone

I think the problem is one of scope.. though I have never tried starting a
session inside a function so I really don't know how it operates.  But if
you do something like..

//
function is_valid($user, $privs)
{
// validate user..
if ($valid) {return TRUE;}
}

if (is_valid($user, $privs))
{
session_start();
session_register(user);
session_register(privs);
}
//

I don't know the answer to your question but this work with out a doubt as
it avoids any unkown problems with the scope of the session variables.

-Kevin

- Original Message -
From: "Jeff Lewis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 16, 2002 12:40 PM
Subject: [PHP] Problem grabbing value of session


> I am in a function called Login2 in which I call the following:
>
> session_start();
> session_register("valid_user");
> session_register("privs");
>
> valid_user contain a name - Jim
> privs contains a number -1
>
> Right after I call those I try a is_registered and it showed that these
> registered correctly.  I removed that code and added a call to another
> function: redirectinternal();
>
> That function is below:
>
> function redirectinternal () {
>  global $valid_user,$privs;
>
>  echo "Login good!";
>  echo "".$valid_user." - ".$privs.$temp;
>
> }
>
> Now, I can't seem to get those values to print to the screen.  I added a
> session_start before the echo and I just can't get my values out...what am
I
> missing?
>
> Jeff
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Problem grabbing value of session

2002-04-16 Thread Erik Price


On Tuesday, April 16, 2002, at 02:40  PM, Jeff Lewis wrote:

> Right after I call those I try a is_registered and it showed that these
> registered correctly.  I removed that code and added a call to another
> function: redirectinternal();

You can avoid the whole "session_register()" business if you simply 
refer to these variables as $_SESSION['valid_user'] and 
$_SESSION['privs'] -- after all, that's what they are, simply session 
variables.  By using this convention, you clarify exactly what kind of 
variables they are each time you write them, which is good for 
legibility later in the future.  Also, you don't need to declare them as 
global in your redirectinternal() function, since any $_* variable is 
considered global at all times.

> That function is below:
>
> function redirectinternal () {
>  global $valid_user,$privs;
>
>  echo "Login good!";
>  echo "".$valid_user." - ".$privs.$temp;
>
> }
>
> Now, I can't seem to get those values to print to the screen.  I added a
> session_start before the echo and I just can't get my values out...what 
> am I
> missing?

You'll have to post the context of this function (how it is called in 
the script) for an answer to this question.


Erik







Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php