Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nocookie traffic redirect?

    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.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did this code:
    PHP 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?

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,627
    Thanks
    6
    Thanked 1,001 Times in 974 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •