Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Checking Cookies Enabled
This is a discussion on Checking Cookies Enabled, within the PHP section. This forum and the thread "Checking Cookies Enabled" are both part of the Programming Your Website category.
![]() ![]() |
Apr 27 2008, 03:15 PM
Post
#1
|
|
|
Squeezing ![]() ![]() ![]() Posts: 81 Joined: 18-February 08 |
Heres my problem:
When a user loads the page I try to create a cookie, then when they submit the form I check whether the cookie was created, then either process the POST or return a message telling them to turn on cookies. Now if they turn on cookies after receiving the message and re-submit the form, it will still tell them they don't have cookies created (because the cookie wasn't created before submitting the form since they previously had cookies turned off). How can I get round this? My thoughts are either:
Thanks Dave |
|
|
Apr 27 2008, 08:59 PM
Post
#2
|
|
![]() Squeezing ![]() ![]() ![]() Posts: 54 Joined: 15-February 08 From: Ottawa, Canada |
You could test if the user has cookies enabled BEFORE even displaying the form:
CODE if (!isset($_COOKIE['test_cookie'])) { if (!isset($_GET['ct'])) { setcookie('test_cookie', 'true'); header("Location: /test.php?ct"); } else { echo "Enable cookies and <a href="test.php">click here</a>!"; exit; } } else { echo "Display form here!"; } 1. First check that my test cookie is set. 2. If yes, display the form (and set your specific cookie). 3. If not, check if ct (stands for cookie test) GET variable is set. 4. If no, set the test cookie and redirect back to same page WITH ct GET variable set. 5. If they are redirected back and test cookie is not set, but ct GET is set, then they must have cookies disabled. Advise them to enable them. 6. If they are redirected back and the test cookie is set, then the form is displayed as in #2 above. -------------------- Blog: annoyed.ca | Web Site Hosting: www.bluephyre.com
|
|
|
Apr 29 2008, 04:05 AM
Post
#3
|
|
|
Squeezing ![]() ![]() ![]() Posts: 81 Joined: 18-February 08 |
Thanks for the suggestion.
The way I am planning to set the site out is the login form will appear on every page, also you don't have to login, it just unlocks extra functionality. (Probably I should have put that in my first post). Using your script, if someone doesn't have cookies enabled, and doesn't enable them because they don't want to log in, on every page that they visit the script will try to set a cookie and then reload the page (for people who do have cookies enabled I will set a session var so its not checked every page). I think only a very small number of people don't have cookies enabled, and I don't know how much of a problem reloading the page each time would create, so would this be a problem or not? Thanks Dave |
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
4 | jamesicus | 271 | 6th April 2008 - 11:33 PM Last post by: jamesicus |
|||
![]() |
2 | djeyewater | 249 | 19th July 2008 - 01:06 PM Last post by: djeyewater |
|||






Apr 27 2008, 03:15 PM






