M
M
m3252015-11-03 14:25:34
JavaScript
m325, 2015-11-03 14:25:34

How to remember user action between pages?

Colleagues, correct me if I didn't ask the question correctly...
The bottom line is this:
There is a pop-up message in the site header with the close selector.

$(".close").on("click",function(){
    $(".message").fadeOut('slow');
});


When clicked, it disappears, but every time the page is refreshed, a message appears again.
Question : How to make a click on a selector cached. So that the person who clicked the button doesn't get a message on subsequent pages?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
L
L0k1, 2015-11-03
@L0k1

cookie, localStorage, sessionStorage not?

Y
Yaroslav Lyzlov, 2015-11-03
@dixoNich

Save a label to the session or local storage about what has already been opened.
And then if (!localStorage.getItem('isOpen')) { open menu }

I
Inwork277, 2015-11-03
@Inwork277

Either cookie or localstorage. Store something like popup_shown = true/false there. On page load, check its value and show/hide your message. When clicked, it changes to false.

A
Alexey Ukolov, 2015-11-03
@alexey-m-ukolov

It all depends on what kind of message you are displaying. If it is the same always and for everyone (for example, notification of planned technical work), then you can really put a flag on the client.
And if you display one-time messages there ("changes saved", "you are registered", etc.), then you need to deal with the server part - why it displays irrelevant messages.

D
Denis Ineshin, 2015-11-03
@IonDen

To hell with half measures! Let's take the Mozilla LocalForage lib !

I
Ivanq, 2015-11-03
@Ivanq

localStorage, localForage, cookies

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question