Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> isset cookie?
mdco
post 6.09.2005, 09:47:21
Post #1





Grupa: Zarejestrowani
Postów: 324
Pomógł: 5
Dołączył: 14.12.2004

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


Jak sprawdzić czy użytkownik ma włączone przyjmowanie ciasteczek?
Chciałem zrobić tak:
1. ustawić ciastko
2. sprawdzić czy się ustawiło i na tej podstawie zdecydować czy jest wł. czy wył.
Ale cookie jest dostępny dopiero po przeładowaniu strony.
Jak zrobić to aby nie odświeżać strony?


--------------------
zmoderowano - rozmiar
Go to the top of the page
+Quote Post
sobstel
post 6.09.2005, 10:07:15
Post #2





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

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


po prostu po ustawieniu ciacha (po pierwszym kroku) przekieruj na inna strone gdzie sprawdzisz czy jest ustawione


--------------------
"If debugging is the process of removing bugs, then programming must be the process of putting them in..."
sobstel.org
Go to the top of the page
+Quote Post
hwao
post 6.09.2005, 13:38:42
Post #3


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




w php to musial bys z przeladowanie strony (albo nawet chyba byla funckja co to sprawdzala, ale w standardzie jej nie ma)

http://pl.php.net/manual/en/function.get-browser.php

a z przeladowanie strony to sprawdzasz czy stowrzy sie cookie

---
btw; mam pewnien pomysl smile.gif potestuje go, jak cos wymysle dam znac:]
Go to the top of the page
+Quote Post
sobstel
post 6.09.2005, 15:00:57
Post #4





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

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


Cytat(hwao @ 2005-09-06 13:38:42)

z manuala z tejże strony :

"The cookies value simply means that the browser itself is capable of accepting cookies and does not mean the user has enabled the browser to accept cookies or not."

i potem

"The only way to test if cookies are accepted is to set one with setcookie(), reload, and check for the value."


--------------------
"If debugging is the process of removing bugs, then programming must be the process of putting them in..."
sobstel.org
Go to the top of the page
+Quote Post
Alchemy_A.R.T.
post 6.09.2005, 17:22:36
Post #5





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 3.09.2005

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


a jak to jest w przypadku js? tam chyba nie trzeba przeladowac; moze sprobowac wyslac przez js
Go to the top of the page
+Quote Post
hwao
post 6.09.2005, 20:05:15
Post #6


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




z js podobnie, poniewaz te dane sa po stronie przegladarki.. (wiec trzeba wyslac wpierw cos i potem sprawdzic obierajac dane czy cos jest:) )
Go to the top of the page
+Quote Post
Spirit86
post 7.09.2005, 13:00:52
Post #7





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

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


  1. <?php
  2. if(!setcookie(...)) die('Włącz obsługę COOKIES');
  3. ?>

nie prościej tak?


--------------------
Audio: Metallica, Soil, RHCP, OffSpring, Green Day, "Retro", Gorillaz, Disturbed, Coma
DB: MySQL 4.1 | php: 4.4.3 Pomogłem Ci? Wciśnij przycisk POMÓGŁ.
Go to the top of the page
+Quote Post
sobstel
post 7.09.2005, 13:35:43
Post #8





Grupa: Zarejestrowani
Postów: 853
Pomógł: 25
Dołączył: 27.08.2003
Skąd: Katowice

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


Cytat(Spirit86 @ 2005-09-07 13:00:52)
  1. <?php
  2. if(!setcookie(...)) die('Włącz obsługę COOKIES');
  3. ?>

nie prościej tak?


nie, ponieważ że wartość zwracana przez setcookie" title="Zobacz w manualu php" target="_manual nie daje odpowiedzi na to czy cookie zostało rzeczywiście ustawione. jak wynika z manuala mówi ona tylko czy "zdążono" ją umieścić w nagłówkach. (If output exists prior to calling this function, setcookie() will fail and return FALSE i wyskoczy oslawione juz "Cannot send headers...")


--------------------
"If debugging is the process of removing bugs, then programming must be the process of putting them in..."
sobstel.org
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 - 21:04