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. Quote 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, ..); } Quote 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? Quote 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> Quote 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! Quote Link to comment https://forums.phpfreaks.com/topic/119993-solved-php-cookies/#findComment-618156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.