-3

In my html magazine reader app i have added day/night mode and font size increase and decrease setting. how do i keep my current night mode and font size into cookies or local storage even if load my next page.

example : pageone.html with night mode & fontsize 24pt. If i load pagetwo.html it should keep previous page settings

is it possible using cookies or local storage? Please help me

Raja E
  • 3
  • 1
  • 1
    yes its possible, and 2 minutes on any decent search engine will solve this for you. – Banana Sep 16 '15 at 13:18
  • What have you tried? It is probably possible with [cookies](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie) or [local storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). Please do some basic research before asking a question. – Drew Gaynor Sep 16 '15 at 13:18
  • possible duplicate of [How do I create and read a value from cookie?](http://stackoverflow.com/questions/4825683/how-do-i-create-and-read-a-value-from-cookie) – Ozan Sep 16 '15 at 13:29

1 Answers1

0

You can store something in the local storage this way:

localStorage.setItem('mode', 'night');

But you shouldn't just rely on JavaScript for that because the client might have turned JavaScript off. It's a bad practice. Your application should be able to handle the issue in the backend using cookies or sessions or even a database depending on your needs

dimlucas
  • 5,040
  • 7
  • 37
  • 54
  • I have read some articles saying that `localStorage` is better than cookies. And also cookies are considered less secure. – Arjun Sep 16 '15 at 13:27