Click to See Complete Forum and Search --> : check to see if cookie is set


brokeDUstudent
09-05-2003, 01:45 PM
Hey how's it going,
I know little to nothing about javascript, but I know it's the solution to my problem.. or atleast I hope anyway. What I'm doing is I'm setting a cookie in PHP when a user logs in and since I can't use PHP files outside of the cgi-bin, I want to use javascript to detect for that cookie and redirect the user to another page. I've found a bunch of cookie redirection scripts, but for a beginner they're a little confusing.

Here is what's being set by the cookie in PHP:

setcookie("id",$md5login,time()+7200,"/",".yoursite.com",0);

which is:

setcookie(name, value, expiration, path, domain, security);

I guess I'm just looking for a way to check if the cookie "id" is set and if it is, redirect to somepage.php. I'd post this in the PHP forums but I think they'd tell me to come here.. thanks for any help you can give me.

pyro
09-05-2003, 01:48 PM
Could you just use PHP to redirect the browser right after it sets the cookie?

setcookie("id",$md5login,time()+7200,"/",".yoursite.com",0);
header("Location:http://www.yourdomain.com/loggedin.php");