Welcome Guest, Not a member yet? Register   Sign In
Set php cookie when user closes modal

I want to be able to set at cookie in php when the user closes a bootstrap modal.

And so when user comes back to that page one show again until cookie expire. 

For some reasons still sets the cookie.

I am not sure how to use local.storage properly for this.

How to make is so when user comes to home page the modal will show and once the user closes modal it will set cookie and stop modal from showing until cookie expire.

Thank you

<script type="text/javascript">

$cookie = "<?php echo $_COOKIE['alert_modal'];?>";

$(document).on('click', '#close_model', function (e) {

    $is_true = true;

    setcookie('alert_modal', $is_true , time() + (86400 * 7)); // 86400 = 1 day



    if ($cookie == false) {

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!

Try setting the cookie in JavaScript:


jQuery cookie is no longer maintained.

It has been replaced with JS Cookie which doe's not require jQuery

A simple, lightweight JavaScript API for handling browser cookies
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB