s1yman Posted August 16, 2008 Share Posted August 16, 2008 Hello all, I was wondering if anyone knows how to activate a cookie upon clicking a button, I first of all tried putting it into a "onClick=" (using a href="javascript:refresh()") with no luck. . . I thought about using a pop-up window which sets the cookie then closes its-self. But that just looks messy. Anyone got any better ideas? Thank you. Link to comment https://forums.phpfreaks.com/topic/119993-solved-php-cookies/ Share on other sites More sharing options...
ignace Posted August 16, 2008 Share Posted August 16, 2008 if (!isset($_REQUEST['my-cookie']) && isset($_REQUEST['specific-button-click'])) { setcookie('my-cookie', $data, ..); } Link to comment https://forums.phpfreaks.com/topic/119993-solved-php-cookies/#findComment-618096 Share on other sites More sharing options...
s1yman Posted August 16, 2008 Author Share Posted August 16, 2008 please excuse my stupidity, but where abouts would that fit into the code? Link to comment https://forums.phpfreaks.com/topic/119993-solved-php-cookies/#findComment-618104 Share on other sites More sharing options...
DeanWhitehouse Posted August 16, 2008 Share Posted August 16, 2008 ok, heres the button <?php if (isset($_POST['create'])) { //create cookie here } ?> <form method="post" action=""> <input type="submit" value="Create Cookie" name="create"> </form> Link to comment https://forums.phpfreaks.com/topic/119993-solved-php-cookies/#findComment-618147 Share on other sites More sharing options...
s1yman Posted August 16, 2008 Author Share Posted August 16, 2008 You leg end!! .. cheers mate! Link to comment https://forums.phpfreaks.com/topic/119993-solved-php-cookies/#findComment-618156 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.