Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Need Cookie Help

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
leatherlips Posted - 11 August 2009 : 21:40:58
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.
1   L A T E S T    R E P L I E S    (Newest First)
leatherlips Posted - 14 August 2009 : 21:33:37
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?

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000 Version 3.4.07