Posted by K Brown on 08/09/06 23:48
In this case the session is limited in scope to the function because the
session is started inside the function. Session variables are typically
global if the session is created globally.
KB
_______________________________________
Hottest Freshest Most Secure Data Backup Period!
www.gpmicro.com
1-877-280-1210
"Squet34785" <Sod@off.com> wrote in message
news:kcsCg.18879$ts3.6883@newsfe2-gui.ntli.net...
> Hello,
> I'm trying to make a function that caches whether or not the user is an
> administrator using a session variable. I've tried the below:
>
> function isAdministrator($username){
> session_start();
> if (!session_is_registered("isAdministrator")) {
> session_register("isAdministrator");
> $db = connectdb();
> $sql = "select username from users where username='$username' and
> type='Admin'";
> $result = mysql_query($sql, $db);
> if (mysql_num_rows($result) > 0) {
> $isAdministrator = true;
> }else{
> $isAdministrator = false;
> }
> }
> return $isAdministrator;
> }
>
> but it always comes back false. Is the session scoped to the function? The
> function is within an external subs file.
>
Navigation:
[Reply to this message]
|