session and subdomains

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpmash
Forum Newbie
Posts: 24
Joined: Mon Oct 31, 2005 6:41 am
Location: Kerala,India
Contact:

session and subdomains

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

session_set_cookie_params()

set the domain value to .mysite.com, note the leading dot.
User avatar
phpmash
Forum Newbie
Posts: 24
Joined: Mon Oct 31, 2005 6:41 am
Location: Kerala,India
Contact:

Post by phpmash »

I used the code
session_set_cookie_params(2000,'/','.mysite.com');
before session_start();
Still it encounters a problem in Firfox
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

show your code.
User avatar
phpmash
Forum Newbie
Posts: 24
Joined: Mon Oct 31, 2005 6:41 am
Location: Kerala,India
Contact:

Post 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
derchris
Forum Commoner
Posts: 44
Joined: Sat Jun 10, 2006 6:14 pm

Post 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.
User avatar
phpmash
Forum Newbie
Posts: 24
Joined: Mon Oct 31, 2005 6:41 am
Location: Kerala,India
Contact:

Post 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
Post Reply