• I’m trying to use the ALA styleswitcher.
    I tested on my machine, but the cookie would not get written using PHP (a search here said that too) so I lobbed it onto my site.
    Both of these fail to set a cookie.
    First is from the ALA article, second is from michel v who commented on it.
    I have no cookie restrictions in place, and js cookies can and are set.
    I know I could use the js file to do it, but this is just annoying me now ??
    What am I doing wrong ?
    <?php
    setcookie ('sitestyle', $set, time()+31536000, ??
    '/', 'tamba2.org.uk/T2/', '0');
    header("Location: $HTTP_REFERER");
    ?>

    <?php
    $set = $_GET['set'];
    $set = preg_replace('#[^a-zA-Z0-9_-]#', '', $set);
    setcookie ('sitestyle', $set, time()+31536000, '/', 'tamba2.org.uk/T2/', '0');
    header('Location: '.$_SERVER['HTTP_REFERER']);
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m going to take a wild stab here and say, could it be the difference between ‘tamba2.org.uk/T2/’ and ‘www.tamba2.org.uk/T2/’ ??
    You didn’t have it on your site so I couldn’t see for sure if that’s the difference or not. I know I read about quite a few problems by people trying to get setcookies to work out on the PHP.net site, and no one seemed to have any real answers.
    TG

    Thread Starter Mark (podz)

    (@podz)

    Ta..just tried that, still no joy.
    I know my switching thing is wrong, but until I can get a cookie set, I can’t really do the ‘trial and error’ until it works.
    Hmmm

    What about this:
    setcookie ('sitestyle', $set, time()+31536000, '/T2/', '.tamba2.org.uk', '0');

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP setcookie’ is closed to new replies.