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

Posted by Squet34785 on 08/09/06 21:11

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

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