View Full Version : Two-part cookie script needed

12-13-2002, 01:26 PM
I submitted a long-winded request last week that got no replies so here is a less verbose version:

First page: need a set cookie script
Second page: need a read cookie + redirect (if the cookie exists).

I tried using an existing script that performs all of those functions on one page but have not been able to rework the script to separate the functions. If anyone wants to look at what I have, it's posted below. Thanks for any help

Existing script:

// page to go to if cookie exists
go_to = "otherpage.html";

// number of days cookie lives for
num_days = 60;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();

function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;

// -->

12-13-2002, 02:32 PM
I have a cookie script that is quite simple to use:
- 3 lines of code to set a cookie, 2 lines to read (you can actually make it 1) plus your redirection line.

12-14-2002, 12:50 AM

12-14-2002, 12:05 PM
hehheh, deacon have you ever tried searching :D

...I posted this for someone anly a few days ago


Dunno if it's what you want (vladdy's is shorter) but it works for me ;)

::] krycek [::