1451 posts
  • Has referred 200+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Member of the Envato Team
+12 more
kailoon Envato team says

I am a little confused about this request, from my client.

They want a welcome box with cookie, user close it and it will not see it again in the next 24 hours. Pretty standard.

However, they request to have an option to change the welcome message and, to be able to reset the cookie as soon as they changed the message.

Does that mean, if the user visit the site and close the box (cookie expiry set to 1 day). Then the admin change the message, reset the cookie. Then the user return to the site in 2 hours and the user will see the box again? And, is that possible?

Any jquery or php expert can help?

2184 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+10 more
revaxarts says

You may use a cookie with a timestamp

showmessage = getCookie('alertbox_12_12_2011');
if(!showmessage){
   //show the message
}
onclosemessage = function(){
    //close box here
   setCookie('alertbox_12_12_2011',1,1);
}

Hope you get the idea.

You can use this getCookie and setCookie function

815 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Contributed a free file of the month
+3 more
rvision_ says
revaxarts said
You may use a cookie with a timestamp
showmessage = getCookie('alertbox_12_12_2011');
if(!showmessage){
   //show the message
}
onclosemessage = function(){
    //close box here
   setCookie('alertbox_12_12_2011',1,1);
}

Hope you get the idea.

You can use this getCookie and setCookie function

+1

You need some hash system to diferentiate cookies for each message. This one won’t work if there are more than 1 message per day, but you get the idea I hope :)

Also, it will be good to keep a list of messages somewhere and delete cookies which are not used anymore. Better solution will be to use JSON and pack all the data in 1 cookie and display only the latest message or something similar.

501 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

there’s no need to store multiple values/cookies, just use one and save timestamp of last message edit.

hide the box if cookie exists and saved timestamp == message, show it and set the cookie if not.

crc32 of message content would also work.

BF

2184 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+10 more
revaxarts says

If the cookie expires after 1 day and you don’t have too many messages you don’t have to delete them explicitly. If you have a couple of messages I would go with pixelentitys approach.

1451 posts
  • Has referred 200+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Member of the Envato Team
+12 more
kailoon Envato team says

You guys are awesome! Thanks for the great help and feedback :)

End up, I am not using timestamp or reset cookie. I create a variable for the client to change the cookie name. So, the new box always get published.

I think this meet the client expectation. - User can close and never see the box until cookie expired. - Client can always update the message and user will see it as soon as it is published.

Anyway, thanks a lot for the advices :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by