Page 1 of 1

session and subdomains

Posted: Thu Jun 08, 2006 1:34 pm
by phpmash
Presently i have a site mysite.com
In the home page users can login.
So I want to use a SESSION variable to store his login name and want to redirect him to user.mysite.com.
But the session variable is not available in subdomin user.mysite.com
In my server php.ini is not available.
So i expect a solution thru coding(ie not using configuration file php.ini)

Thanks
:roll:
phpmash

Posted: Thu Jun 08, 2006 2:04 pm
by feyd
session_set_cookie_params()

set the domain value to .mysite.com, note the leading dot.

Posted: Sat Jun 10, 2006 1:11 pm
by phpmash
I used the code
session_set_cookie_params(2000,'/','.mysite.com');
before session_start();
Still it encounters a problem in Firfox

Posted: Sat Jun 10, 2006 1:59 pm
by feyd
show your code.

Posted: Sun Jun 11, 2006 10:35 am
by phpmash
session_set_cookie_params(2000 , '/', '.sub.mysite.com');
session_start();
$_SESSION['usname'] = $username;

This has been set in sub.mysite.com's index.php page.
Now in mydata.php page the
"$_SESSION['usname'] " is not available with error in FireFoxin IE it is OK.
"Redirection for this URL exceded.Unable to load the requested Page.This may be caused by cookies that are blocked"

Expecting Your Advice
phpmash

Posted: Sun Jun 11, 2006 10:51 am
by derchris
You say only FF has problems, IE is ok.
So there should be a problem with yout FF config.
Check the Cookie options.

Posted: Sun Jun 11, 2006 3:09 pm
by phpmash
Thanks...
I got it.
In FF, cookie settings my site was already entered in exceptions tab.
(Tools->options->cookie->exceptions)
So cookie was not creaated.
Thanks a lot
phpmash