session variable across subdomain

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
prue_
Forum Commoner
Posts: 64
Joined: Thu May 07, 2009 10:34 pm

session variable across subdomain

Post by prue_ »

hi, can someone help me.. I have a login form that uses session variables.. It's working perfect with folder based.. how can I make it work with the subdomain.. the subdomain don't recognize the session I set.. here's the code on my subdomain page

Code: Select all

 
code deleted
 
this is a snip of code from domain/index (with the login form)

Code: Select all

 
code deleted
 
I tried to google it and find this:
will this code helps? don't know where to place this though

Code: Select all

ini_set("session.cookie_domain",".domain.com") ;
thanks a lot, I hope someone can help me.. I'm starting to go crazy, I've been doing this for hours already.
Last edited by prue_ on Fri Feb 05, 2010 6:16 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: session variable across subdomain

Post by requinix »

Edit your php.ini and change the cookie_domain there.

Don't forget to restart the web server.
prue_
Forum Commoner
Posts: 64
Joined: Thu May 07, 2009 10:34 pm

Re: session variable across subdomain

Post by prue_ »

where can I find php.ini? will this solve my problem?
thanks!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: session variable across subdomain

Post by requinix »

prue_ wrote:where can I find php.ini?
phpinfo can tell you.
prue_ wrote:will this solve my problem?
I wouldn't have suggested it if I thought otherwise.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: session variable across subdomain

Post by flying_circus »

You should also be able to change the value in your script at runtime using ini_set("session.cookie_domain", "myDomain"); Be sure to change the value BEFORE you start your session.
prue_
Forum Commoner
Posts: 64
Joined: Thu May 07, 2009 10:34 pm

Re: session variable across subdomain

Post by prue_ »

thanks to both of you.. @tasairis, I shouldn't have said that.. :)

but can't find it in ftp.. the path says /usr/local/lib/php.ini.. am I not supposed to find it in ftp? where else could it be?

thanks again
Post Reply