D
D
Darklt2018-03-01 21:08:49
JavaScript
Darklt, 2018-03-01 21:08:49

js cookies don't work to show message 1 time?

Good evening, the library is connected

https://cdn.jsdelivr.net/npm/[email protected]/src/js.cookie.min.js

and popup script:
function diplay_hide (blockId)
{ 
    if(!Cookies.get("checker")) {
        Cookies.set('checker', 'value', { expires: 30 });
        $(blockId).animate({height: 'show'}, 500);
    } else {     
        $(blockId).animate({height: 'hide'}, 500); 
    }
}

and the popup itself:
<div class="personal-data" id="block_id"><div class="personal-data-warning">ТЕКСТ<a class="close"  onclick="diplay_hide('#block_id');return false;" id="setCookie" ></a></div></div>

It does not give any errors, but it does not work either, when the page is reloaded, the window appears again.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2018-03-01
@SagePtr

What does expires: 30 mean? I suspect that the time in milliseconds is transferred there, or the time elapsed since 01/01/1970, in which case your cookie almost instantly goes rotten or comes already rotten.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question