# Switch backgrounds upon return

**URL:** <https://forum.kirupa.com/t/switch-backgrounds-upon-return/185896>\
**Category:** Uncategorized\
**Created:** [April 17, 2006, 3:00pm UTC](https://forum.kirupa.com/t/switch-backgrounds-upon-return/185896 "2006-04-17T15:00:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rawnewdlz](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@rawnewdlz](https://forum.kirupa.com/u/rawnewdlz)\
**Post date:** [April 17, 2006, 3:00pm UTC](https://forum.kirupa.com/t/switch-backgrounds-upon-return/185896/1 "2006-04-17T15:00:15Z")

</div>

Hi, any recommendations on switching a background say, start w/the sun and if a user returns to the homepage it will be dark w/the moon?

(Not necessarily using flash)

any suggestions would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![hl1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hl1/32/849_2.png) [@hl1](https://forum.kirupa.com/u/hl1)\
**Post date:** [April 17, 2006, 3:34pm UTC](https://forum.kirupa.com/t/switch-backgrounds-upon-return/185896/2 "2006-04-17T15:34:54Z")

</div>

Done that. I use PHP but you can use JS.

Use the date object to get the hour (use the 24 hour version). Then use an if statement for checking whether it is between times of night (using \<= =\> \<\>), or day.

edit:/ Oh you didn’t want to switch at day and night, just user return. Set a cookie upon visit as to what background they used (sun to start). Then upon return have it check whether the cookie exists and that the referer wasn’t a page of your site. If the cookie exists, change the value of the cookie, and make the background night. If it doesn’t, create it, and make it day.

---

<div class="post-metadata">

**Author:** ![rawnewdlz](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@rawnewdlz](https://forum.kirupa.com/u/rawnewdlz)\
**Post date:** [April 17, 2006, 3:43pm UTC](https://forum.kirupa.com/t/switch-backgrounds-upon-return/185896/3 "2006-04-17T15:43:34Z")

</div>

cool thanks. I’m not familiar w/using cookies but I’ll check it out.
