Click to See Complete Forum and Search --> : Redirect help needed please


winchester169
09-23-2003, 02:48 AM
I need some help. I have searched the web for 2 days and searched all of this forum and found little snippets I almost could use (some gave me "object expected" errors (????))

What I have is two pages:

Page one is a redirect from paypal.

What I need to do here is set a cookie with any value then redirect to another page.

(this is working for the redirect)
<sc+ript language="javascript">
<!--
location.replace("http://my.url/file.html");
-->
</sc+ript>

Page two needs to do two things. Check for the existence of the cookie and if found, leave the page in the browser but delete the cookie so the user can not return to the page again by bookmarking it or typing it in the address bar etc etc etc.

If the cookie is not found (see above) redirect to another page.

Thank you so very much in advance.

-Jered

Khalid Ali
09-23-2003, 08:20 AM
there are cookie scripts all over these forums,search for cookie,
you will need to
set cookie and get cookie in the first page and in the redirect page you will only need to write cookie( since you are deleting it)

here is a link...
http://forums.webdeveloper.com/showthread.php?s=&threadid=17959

winchester169
09-24-2003, 03:27 AM
Okay, so I played with it a bit and am still stumped. I get it to almost behave but there is a problem (I am so very new at Javascript it hurts)

Page one has the following:

<sc+ript>
function allow(){
document.cookie="sitelock=securedeniedno"
var beginindex, endindex, result
beginindex=document.cookie.indexOf("sitelock")+9
endindex=beginindex
while (document.cookie.charAt(endindex)!=";"&&
endindex<=document.cookie.length)
endindex++
var result=document.cookie.substring(beginindex,endindex)
location.replace("http://my.url/get.html")
}
</scr+ipt>


<scr+ipt>
allow()
</scr+ipt>

and page 2 has the following:

<scr+ipt>
function allow(){
var beginindex, endindex, result
beginindex=document.cookie.indexOf("sitelock")+9
endindex=beginindex
while (document.cookie.charAt(endindex)!=";"&&
endindex<=document.cookie.length)
endindex++
var result=document.cookie.substring(beginindex,endindex)
if (result='securedeniedys'){
location.replace("http://my.url/index.html")
}
}
</scri+pt>

<scri+pt>
allow()
</sc+ript>



<a href="./list1.html" onclick="document.cookie='sitelock=securedeniedys'">getit</a>

I figgure with all my other mistakes that the onclick wont work but I dont even get there. For some reason the cookie is already set to "sercuredeniedys" and I am automatically forwarded.

What am I doing wrong please?

Also, if you do have an answer, before I go and mess thisg up more how would I make this cookie persistant for say, 1 year?

Thank you again.