When creating a OO project that holds members and stuff (like a weblog), when should i deal with the sessions?
Should I make a whole new class dealing with my sessions or should I store my session data in my member class (dealing with login and logout functions)?"????
sessions and OOP
Moderator: General Moderators
Aye, well I was programming my member class and come across a problem... how should I store my sessions... or whens hould I impliment my sessions...
I got this far then stopped confused as to what would be a good idea...
instead should i just make a seperate session class that deals with the session data?
I got this far then stopped confused as to what would be a good idea...
Code: Select all
class Member extends core{
session_start();
$_SESSION['auth'];
$_SESSION['id'];
$_SESSION['restrictions'];
var $dbid;
var $dbusername;
var $dbpassword;
var $dbrestrict;
function login($username,$password){
$this->query("SELECT * FROM godschildren WHERE username='$username'");
if($this->getRows() == 0){
return 0;
}
$this->Assoc();
$this->setVars($this->getData());
if($this->dbpassword == $password){
$_SESSION['auth'] = 1;
$_SESSION['restrictions'] = $this->dbrestrict;
$_SESSION['id'] = $this->dbid;
return 1;
}
}
function logout(){
$this->dbid = "";
$this->dbusername = "";
$this->dbpassword = "";
$this->dbrestrict = "";
$_SESSION['auth'] = 0;
$_SESSION['restrictions'] = "";
$_SESSION['id'] = "";
}
function setVars($data){
$this->dbid = $data['id'];
$this->dbusername = $data['username'];
$this->dbpassword = $data['password'];
$this->dbrestrict = $data['restrictions'];
}
function isLoggedIn(){
if($_SESSION['auth'] == 1){
return 1;
}else{return 0;}
}
}