Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Problem przy ustawieniu cookies
crac2003
post 1.06.2009, 23:24:07
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 17.10.2007

Ostrzeżenie: (0%)
-----


Witam

Mam taki problem. Otóż przy ustawianiu cookies (strona logowania - powiedzmy www.mojadomena.pl/Login/Check.html) ciasteczko jest widoczne poprawnie. Natomiast jeśli po przejściu na stonę www.mojadomena.pl ( header("Location: www.mojadomena.pl")) ciasteczka nie ma. Dajcie mi jakieś namiary co może być nie tak bo już siedze nad tym 3 dzień.

Pozdrawiam
Go to the top of the page
+Quote Post
marcio
post 2.06.2009, 00:00:13
Post #2





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


Moze kod zapodasz wrozka o tej porze juz spi biggrin.gif


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post
crac2003
post 2.06.2009, 08:03:31
Post #3





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 17.10.2007

Ostrzeżenie: (0%)
-----


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())winksmiley.jpg
Go to the top of the page
+Quote Post
batman
post 2.06.2009, 08:10:47
Post #4





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Ustaw ścieżkę w setcookie na / - czwarty parametr.
Ustawiając ciacho w ścieżce /Login, nie jest ono widoczne w ścieżce / i stąd Twoje problemy.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 6.07.2025 - 23:56