PHP setcookie
-
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']);
?>
- The topic ‘PHP setcookie’ is closed to new replies.