Reset cookie when content file is saved

Hi, I’m trying to create a simple notification system for a website I’m building. The admin will be able write a message in the panel and it will appear in a little notification box.

The user will be able to dismiss the notification which would set a cookie so they wont see it again but I’m wondering if its possible to reset the cookie when the admin changes the content of the notification so users will see it again?

Thanks

May be :

  • Default : cookie001
  • After update : cookie002

Yes ?

@dsply Hi, thanks for the reply. I was wondering if there would be a way to do this automatically, using PHP, so once the page content has been updated, the cookie would be automatically reset.

You could use panel hooks: http://getkirby.com/docs/panel/hooks

How about storing the page modified timestamp in the cooke?
From $page->modified() (http://getkirby.com/docs/cheatsheet/page/modified) - and then comparing the cookie timestamp with the current timestamp to only show the notification if a cookie is set and if the cookie’s timestamp differs from the current page modified timestamp.

I didn’t really understand how Hooks work, but it seems like what I would need though. Do you have an idea of how to use them? Thanks

This seems promising. Could you help me with how to set the cookie on a button click and how to write the if statement for the check? Thanks