User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,711 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,399 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Quick Help for Cookie script?

Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Quick Help for Cookie script?

  #1  
Jan 20th, 2007
hello again Dani web folk, Im needing a little help with an example script. This cookie setter is prewritten but I want to set it up for use on my site but im not sure how. I want to redirect from here

http://herproom.5.forumer.com/index.php?

to here

http://download3-1.files-upload.com/.../20/22/RP.html

only once, the first time someone visits my site.

Please help me configure this code? much appreciated.

<script type="text/javascript">
// adapted from http://evolt.org/article/list/20/416/
// <![CDATA[
var Splash = GetCookie('SplashSkip');
ReDirect('/welcome');
function ReDirect (URL) {
SetCookie('SplashSkip','TRUE',1);
if (Splash == 'TRUE') {
window.location=(URL);
}
}
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, expDays, path, domain, secure) {
// Set cookie with name, value etc provided
// in function call and date from above
// Number of days the cookie should persist NB expDays='' or undef. => non-persistent
if (expDays != null ) {
var expires = new Date(); 
expires.setTime(expires.getTime() + (expDays*24*60*60*1000));
} 
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
// ]]>
</script>
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 1:56 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC