开发者

showing tips or announcements when sites and store info in cookies

how to use cookies to store whether a particular announcement is show to user.

for example when we open stackoverflow for first time, it will show an announcement to read FAQ, if we close the announcement, the next开发者_如何学Go time we open the site the announcement won't shown. so this information is stored in cooki. am i correct?

any advice will be highly appreciated.

Thanks

Rifky


Yes.

You store a cookie, say named "announcement_seen".

Before displaying the announcement, you check the cookie value (on backend or front end, doesn't matter), and if it's 1, you don't display it.

When you DO display the announcement, you run a JavaScript on the browser to set the cookie value to 1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜