Reply to Re: Session problem

Your name:

Reply:


Posted by mabobine on 10/23/07 10:13

if($session->userHasSession($user['id'])) {
throw new Exception('You can only have One session at a time. Please
wait for the other session to expire.');
}


public function userHasSession($user_id)
{
$this->cleanup();

// Check first, that the User exists on the Database
$query = 'select * from `users` where id = {user_id}';
$query_subst = array('user_id' => $user_id);
$mysqlres = mysqlConn::executeQuery($query, $query_subst);
if(mysql_num_rows($mysqlres) < 1) {
mysql_free_result($mysqlres);

// Block remaining operations, because the User is not valid on the
system
die("Exception: User requesting the Session is invalid!");

return false;
}

// Now, check if there is a Session for this User
$query = 'select * from `' . $this->table . '` where user_id =
{user_id}';
$mysqlres = mysqlConn::executeQuery($query, $query_subst);
if(mysql_num_rows($mysqlres) > 0) {
mysql_free_result($mysqlres);
return true;
} else {
mysql_free_result($mysqlres);
return false;
}
}

public function killSession()
{
if($this->started)
{
$query = 'DELETE FROM ' . $this->table . ' WHERE id =
{session_id}';
$query_subst = array('session_id' => $this->session_id);
if(mysqlConn::executeQuery($query, $query_subst))
{
setcookie('session_id', '', time() - 259200);

return true;
}
}

return false;
}

[Back to original 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

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