Code: Select all
if (setcookie('planview', 'yes', time() + 86400 * 30) == TRUE) {
echo $_COOKIE['planview'];
}
else {
echo "Cookie no Workie";
}Can anyone tell me why this may not be working?
Thanks
Moderator: General Moderators
Code: Select all
if (setcookie('planview', 'yes', time() + 86400 * 30) == TRUE) {
echo $_COOKIE['planview'];
}
else {
echo "Cookie no Workie";
}Code: Select all
if(isset($_POST['FormThingo'])){ // USER FILLS IN FORM
setcookie('planview', 'yes', time() + 86400 * 30) //SETS COOKIE
// EMAIL CLIENT THE QUESTIONAIRE DETAILS
include($theplan.".php"); //VIEW PLAN
}
elseif(isset($_COOKIE['planview'])) { // CHECKS FOR COOKIE ALREADY SET
include($theplan.".php"); //VIEW PLAN
}
else {
// QUESTIONAIRE
}Code: Select all
session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params().
Note: The expiration timestamp is set relative to the server time, which is not necessarily the same as the time in the client's browser.Code: Select all
if(!isset($_COOKIE['planview'])) {
if (setcookie('planview', 'yes', time() + 86400 * 30) == TRUE){
echo "Cookie Set";
}
else{
echo "Cookie Not Set";
}
}
elseif(isset($_COOKIE['planview'])) {
echo "Cookie Works";
}Code: Select all
if (FORM SUBMITTED){
if (setcookie('planview', 'yes', time() + 86400 * 30) == TRUE){
echo "Cookie Set";
}
else{
echo "Cookie Not Set";
}
// FORM/EMAIL STUFF
}