/    Sign up×
Community /Pin to ProfileBookmark

Cookie question – release a cookie after a specific time.

I’ve added a small javascript that opens a lightbox pop-up window when you visit a home page of a website.

And I’ve added a cookie to prevent the pop-up from reoccurring. The lightbox will open the next “session” of the browser. (quit out of the browser, reopen it, and the lightbox pop-up appears again) That’s good, but I’d like to add a timer to it as well. So if you don’t quit the browser, but revisit the home page after a certain time, the lightbox will appear again – then go away for a time again.

It’s a specific function, we want for the website, but although I’ve found a few possible solutions, but I’m not a skilled enough Javascripter to know if they aren’t compatible, or if I’m entering the syntax incorrectly. I’m sure it’s probably the later.

I’m sure there’s probably a simple solution, but I need a little help.

This is the script:

[CODE] <script>
if (document.cookie.indexOf(“fade=”) == -1) {
var now = new Date();
document.cookie = “fade=yes”;

$(document).ready(function () {

$(‘#fade’).popup({
transition: ‘all 0.5s’,
autoopen: true,
scrolllock: true
});

});
}
</script>
[/CODE]

If anyone can either let me know how to add the extra cookie, or point me in the right direction, I’d appreciate it. Thanks.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumOct 05.2015 — As far as I understand you, your problem should be solved by using the max-age attribut of a cookie:

http://www.thesitewizard.com/javascripts/cookies.shtml
×

Success!

Help @ptrautwein spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...