Page 1 of 1
cookies, on a sub domain?
Posted: Fri Jun 25, 2004 1:25 pm
by Ne0
Hi everyone. Im using an invision forum on my website, and i want to make it so when your logged in on the forum, your logged in on the website. Ive made it so my registration and everything uses the same table/database, and ive got all that, what my problem is invision used cookies to store login info. So i did some searching and pulled up the cookie that stores the info, and made this:
Code: Select all
<?php
if (isset($_COOKIE['member_id'])) {
$infotemp = explode("-",$_COOKI['member_id']);
$userid = $infotemp[0];
echo "HEY $userid";
} else {
echo "NOT SET!";
}
?>
it didnt reconize that the cookie was set, so i scratched my head for a few seconds, and realized that the cookie was set for forums.mydomain.com, not mydomain.com, wich is were the site is. Is there anyway to get around this? Am I wrong and this is not the problem?
Thanks in advanced.
Posted: Fri Jun 25, 2004 2:16 pm
by tim
not looking at your logic, but correct the syntax error
$_COOKIE, not $_COOKI
also, make sure the path in the setcookie is set to all subdomains.
go to php.net and search for setcookie() for more info
Posted: Fri Jun 25, 2004 3:16 pm
by lostboy
straight from the
manual
To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to
http://www.example.com will make the cookie only available in the www subdomain. Refer to tail matching in the spec for details.
Posted: Fri Jun 25, 2004 3:35 pm
by Ne0
Ok, thank you, i know now that the cookie isnt being set for all domains. I found out that they are setting the cookie through Javascript, i modifed it to this:
Code: Select all
document.cookie = ipb_var_cookieid + name + "=" + value + "; expire=" + expire + "; domain=.ne0.fgvhost.net;"
then, i did a simple test to see if that worked. It sais "NOT SET!", i moved the file that im working on into the forums subdomain, ran it, and it printed "HEY" and the value of the cookie.
i made some progress...but now im stuck. how can i get it to set the cookie for all domains?
Posted: Fri Jun 25, 2004 3:38 pm
by feyd
make sure to set the path to /
Posted: Fri Jun 25, 2004 3:45 pm
by Ne0
nothings working. i tried:
Code: Select all
document.cookie = ipb_var_cookieid + name + "=" + value + "; expire=" + expire + "; domain='.ne0.fgvhost.net'; path='/';";
and
Code: Select all
document.cookie = ipb_var_cookieid + name + "=" + value + "; expire=" + expire + "; domain=ne0.fgvhost.net; path=/;"
i dont know whats wrong
Posted: Fri Jun 25, 2004 3:46 pm
by feyd
what's wrong with using [php_man]setcookie[/php_man]()?
Posted: Fri Jun 25, 2004 3:48 pm
by Ne0
i dont know? ask the people who wrote ipb 2.0, im just trying to get it so when your logged in on the forum your logged in on the site and vis versa. i dont want to mess with things to badly, because im afraid i might mess something up. i guess i will try using setcookie() now, but im going to have to modify alot of things
Posted: Sat Jun 26, 2004 12:01 am
by ol4pr0
i guess u could just use setcookie() from php, since later on i do not think that the script will make any destinct wether the cookie has been set with java or php ...