...

View Full Version : cookie limiting popup



starrwriter
07-11-2004, 06:48 AM
A few years ago I had a script that set a cookie to limit the number of times a popup window was opened for a particular viewer. All I can find now is a limit on the number of days. Anyone know where I can look?

Vincent Puglia
07-11-2004, 04:32 PM
Simply create a var that increments each time you write the cookie. If the var value exceeds your max, don't display the window. Search the net for Write Once Cookie.

Vinny

Willy Duitt
07-11-2004, 04:51 PM
Or, if this is for sessions only you can use the window.name property to store the counter. The below two lines placed at the top of your popup function should work and not be disabled with cookies disabled....

function popUp(){
window.name = (window.name*1)+1;
if(window.name > 3){ return false }

// REST OF POPUP CODES HERE //

}

.....Willy

starrwriter
07-11-2004, 11:20 PM
Or, if this is for sessions only you can use the window.name property to store the counter. The below two lines placed at the top of your popup function should work and not be disabled with cookies disabled....

function popUp(){
window.name = (window.name*1)+1;
if(window.name > 3){ return false }

// REST OF POPUP CODES HERE //

Thanks, Willy. That looks like it will work.

canadianjameson
07-12-2004, 05:12 AM
interesting willy... whats the logic behind the code?

i assume it doesnt work if the user closes the browser and returns later, as it seems it isnt loading anything into the users temp files...

if the user has his cache/temp files settings set to "download from server every time", does this still work?

Willy Duitt
07-12-2004, 05:32 AM
interesting willy... whats the logic behind the code?
You can set and read the window.name property in IE3+, N3+...
And if you set the window.name, you can read it back and use its value as you like....


i assume it doesnt work if the user closes the browser and returns later, as it seems it isnt loading anything into the users temp files...
Correct, it is session only. Once the browser is closed, you lost the session....



if the user has his cache/temp files settings set to "download from server every time", does this still work?
You are not downloading or placing anything on the users machine which, for sessions, I find the use of the window.name property more useful than cookies since cookies can be disabled.....

.....Willy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum