You are here: Re: Session scope « All PHP « IT news, forums, messages
Re: Session scope

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация