0

I need to refresh a web page on the time i get from the user. That's fine. But how i do make

that permanent. Say, the user selects 30secs, and makes it permanent, I need to refresh every

30 secs. I tried $_SESSION, ineffective. Pls don't suggest cookies.

ineedhelp
  • 125
  • 2
  • 9
  • 2
    You need to use cookies, or POST it to the session. – SLaks Feb 20 '11 at 03:39
  • but what if cookies have been disabled? – ineedhelp Feb 20 '11 at 03:40
  • 1
    Agreed that cookie must be used, or you must send the selected time back to the server to be stored in session and outputted on subsequent page loads. – JAAulde Feb 20 '11 at 03:43
  • @JAAulde: how to know whether the client has enabled them? – ineedhelp Feb 20 '11 at 03:45
  • In the [javascript cookie library](http://code.google.com/p/cookies/) I wrote, I test by trying to set a cookie and then reading it back. If I don't get back my value, I know cookies are not enabled. I exposed this functionality with a test() method. – JAAulde Feb 20 '11 at 03:48
  • If you are asking about cookies being disabled, what about if JS is disabled? It kind of blows the whole thing out of the water. – picus Feb 20 '11 at 04:01

2 Answers2

0

if cookies disabled, try using localstorage instead...

DrStrangeLove
  • 11,227
  • 16
  • 59
  • 72
  • Srsly? If cookies are disabled then the odds of the user having a browser that implements localstorage or that user has enabled it are basically zero. – Prestaul Feb 20 '11 at 06:47
0

You'll need to persist the user's selection in some manner.

Cookies, session variable server-side, URL query parameter, localstorage - these are all options.

URL query parameters and SLaks's suggestion of POSTing let you keep different settings for different tabs opened simultaneously, if that matters to you.

EDIT: by URL query parameter I mean redirection, using window.location, to something like http://example.com/foo?refresh=30 and later parsing window.location.searchyourself or using existing code for it.

Community
  • 1
  • 1
orip
  • 73,323
  • 21
  • 116
  • 148