Oto kod:
Plik Login:
CODE
protected function CheckLogin(){
$login = $_POST["login"];
$password = $_POST["password"];
if(empty($login) || empty($password)){
$this->lastError = "Musisz wypełnić obydwa pola";
return;
}
$login = htmlspecialchars($login);
$login = mysql_escape_string($login);
$this->siteCore->Auth()->CheckLogin($login, $password);
if($this->siteCore->Auth()->IsAuthorizated()){
header('Location: '. $this->siteCore->GetURL());
}else{
$this->lastError = "Błąd autoryzacji";
}
}
Plik z funkcja Auth()
CODE
$login = htmlspecialchars($name);
$login = mysql_escape_string($login);
$sql = "SELECT * FROM tb_users WHERE Login = '".$login."'";
//pobieranie danych z bazy
...
if(strcmp(trim($res[0]["pm_Password"]),md5(trim($password))) == 0){
$this->userData = new UserData();
$this->userData->userName = $res[0]["pm_Login"];
$this->userData->userPassword = $res[0]["pm_Password"];
$this->userData->userRights = $res[0]["pm_Rights"];
$this->userData->userTypedPassword = trim($password);
$this->userData->userEmail = $res[0]["pm_Email"];
setcookie ("TestCookie", serialize($this->userData), 0);
}
I jak już wspomniałem po wykonaniu tego kodu i przejściu na stronę główną nie widzi ciasteczka. Co ciekawe ciasteczko jest jeśli pozostaje na danej podstronie (czyli nie wykonam header('Location: '. $this->siteCore->GetURL())