Good day! Send an inexperienced)) There is a page with a bunch of checkboxes, different names, many of them ... Tell me how to do that when you refresh the page, their state is "remembered"?

I understand that I need the function $ ("input: checkbox: checked"), but I don’t know how to use it! Well, no way jquery is given to me ((

    1 answer 1

    Usually LocalStorage and / or user session is used for this. The session stores data for the current page, and LocalStorage contains anonymous data, that is, the user may not be authenticated on the site. In general, there are many examples of using this functionality on the Web:

    Record value:

    localStorage.setItem('myCheckbox', true); 

    Reading:

     var myCheckbox = localStorage.getItem('myCheckbox'); 

    Clear all values:

     window.localStorage.clear(); 
    • what did you mean by session? pkhp-session which is stored on server side, or sessionStorage ? and why information is stored there only for the current page. Is it possible to record something in the session without authentication? And then it seems you can not, but in fact you can. - teran
    • Under session also meant PHP server session. On the server, you can store information for any page, and in sessionStorage - only for the current, unfortunately. - Daniel Protopopov
    • You have a good reason to re-read help about sessionStorage , since this repository works for the time you are on the site, regardless of whether one page is open or you go to the next. localStorage , in contrast, allows you to save data and offline when you leave the site, but its size is limited. - teran
    • @teran Then, in principle, you can use localStorage or sessionStorage - as a result, they both inherit Storage. - Daniel Protopopov