Google Groups

Update notifications cookie May 8, 2012 3:35 AM
Posted in group: google-appengine-go
I'm trying to set a cookie through javascript to show that one page (ie. the News page) have been updated within my website. This must be shown on every page of this website and should disappear only when the news page has been visited...
For now, i can make it work on every pages calling through an external js file, but the notification disappears when i visit ANY page, not only the News page. I want it to be a bit like facebook: Shows the notification as long as you haven't visited the right page.

Here is the code i have. How should i change it?

in the body of the page (calling the scripts):

<script type="text/javascript" src="newsupdate.js"></script><script type="text/javascript" src="newsupdatecall.js"></script>

File newsupdate.js:

now = new Date
expireDate = new Date
lastVisit = new Date(cookieVal("news"))
document.cookie = "news="+now+";expires=" + expireDate.toGMTString()

function cookieVal(cookieName) {
  thisCookie = document.cookie.split("; ")
    for (i=0; i<thisCookie.length; i++) {
      if (cookieName == thisCookie[i].split("=")[0]) {
        return thisCookie[i].split("=")[1]
  return "1 January 1970"

function newChecknews(yyy,mm,dd) {
  lastChgd = new Date(yyy,mm-1,dd)
  if (lastChgd.getTime() > lastVisit.getTime()) {
    document.write("Page updated !!")

File newsupdatecall.js :


I would like the cookie to be read on every pages of the website, showing "Page updated" beside the menu of News page, and disappear ONLY when News page have been visited... How should i do?
Thank you very much!!