...

View Full Version : Nocookie traffic redirect?



JACOBKELL
04-22-2011, 09:48 PM
Is it possible to redirect users which dont have support for cookies to set url?
I know you can done for users which coming for first time but that is made for users which have support for cookies while in this case it should simply redirect users which dont have support for cookies.

_Aerospace_Eng_
04-22-2011, 09:59 PM
The only way I see this working is if you attempt to set a cookie, reload the page (cookies only exist on the next page load), check for the cookie you set previously, if it isn't there redirect to the non cookie page.

JACOBKELL
04-25-2011, 12:44 AM
I did this code:


<html>
<body>
<?php
$value = "my cookie value";
setcookie("user","$value", time() + 604800);
if (!isset ($_COOKIE['user']))
header ("Location: nocookie.php");
else
header ("Location: foundcookie.php");
?>
</html>
</body>

And seems you are right,it works only after reload.Perhaps is there another way to detect noocookie browser?

_Aerospace_Eng_
04-25-2011, 01:25 AM
Well the php.net manual has this function

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

But it can only tell you if the browser is capable of accepting cookies but not if the user has this enabled or not. They say the only way to check is the way that you have discovered.

Another possibility which would involve javascript (using ajax).

You set a cookie with javascript, talk to a php script using ajax, the script can now check for the cookie (without reloading) as the call to the php script is the "reload". The php will echo true or false depending on if the cookie was set. The only problem is this won't work if the user has javascript disabled.

VIPStephan
04-25-2011, 01:59 PM
The only problem is this won't work if the user has javascript disabled.

In which case you could redirect to the no-cookie page by default. Which leads to the thought that you’d actually provide the no-cookie page by default and then redirect to the page using cookies if they are enabled.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum