setcookie fails inside shortcode
-
I am not able to set a cookie from inside a shortcode. inside my test WordPress site [ redundant link removed ] the setcookie returns FALSE. Inside a non-WordPress environment(apps.stratusconcept.com/zohotest/cook.php) the function works fine.
Here is the code for the basic function:
add_shortcode("SC-PVT", "sc_pvt_sc"); function sc_pvt_sc(){ if(isset($_COOKIE['scvttest'])) { echo "Cookie is set!<br>"; } else { echo "Cookie is NOT set!<br>"; $res = setcookie("scvttest","1234",0,"/",$_SERVER['HTTP_HOST']); if ($res){ echo "-- TRUE --"; } else { echo "-- FALSE --"; } } }
The page I need help with: [log in to see the link]
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘setcookie fails inside shortcode’ is closed to new replies.