Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Need Cookie Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

leatherlips
Senior Member

USA
1838 Posts

Posted - 11 August 2009 :  21:40:58  Show Profile  Visit leatherlips's Homepage  Reply with Quote
I have made a link in the forum that opens a pop up. The pop up brings up a "Terms and Conditions" page. The member has to agree in order to proceed to the "Main Page".

What I am trying to do is have the "Terms and Conditions" page only appear once during the browser session if they agree. So if they click the popup link again they will go right to the "Main Page".

I'm not sure how to write the cookie to do that or where to place the code.

Mangione Magic Forum - The Music of Chuck Mangione

My Mods: Googiespell MOD | Link To Reply MOD | Petition MOD | Contact Page MOD | Share This Topic MOD | MP3 MOD | PageEar MOD | Google Viewer MOD

leatherlips
Senior Member

USA
1838 Posts

Posted - 14 August 2009 :  21:33:37  Show Profile  Visit leatherlips's Homepage  Reply with Quote
I think I have it working. I found this script and it seems to be working OK. I have one question though. The part in red seems a bit clumsy:
var expDays = 1;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var favorite = GetCookie('uploadagree');

if (favorite != null) {
switch (favorite) {
case 'uploadagree' :    url = 'pop_upload_new.asp';
      break;
case 'nonexist' : url = 'nonexist.html';
      break;
}
window.location.href = url;
}


The part:

      break;
case 'nonexist' : url = 'nonexist.html';
      break;
was added to make it work because the original script had several choices. Since I only have one checkbox (uploadagree) I made up another one (nonexist) to get it to work. Is there a way to rewrite that to not use a case?

Mangione Magic Forum - The Music of Chuck Mangione

My Mods: Googiespell MOD | Link To Reply MOD | Petition MOD | Contact Page MOD | Share This Topic MOD | MP3 MOD | PageEar MOD | Google Viewer MOD
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000 Version 3.4.07