tags:

views:

68

answers:

1

Hi .... I create two application, let say my first application called mastersite, and the second application called childesite. I store the childesite project under the mastersite project directory.

I create virtual host in my apache server, and the document root of the directory point to masterproject directory supposed the virtual host name is www.mastersite.com. after that i create sub domain of virtual host supposed the subdomain of virtual host name is, www.childesite.mastersite.com.

while www.mastersite.com is opened by a browser, the application stored the dummy data to its session. Supposed I name it to dummy_data, and the dummy_data set to '123'. dummy_data = '123';

while www.childesite.mastersite.com is opened, it will read the dummy_data from the mastersite.com domain and print out the dummy_data to the browser. but The www.childesite.mastersite.com is blank, because it can't read the domain session.

but, if i try open the childesite using www.mastersite.com/childesite the dummy data will be printed out to the browser.

why these thing could by happened ?

+3  A: 

Before initializing session put this line:

ini_set ( 'session.cookie_domain', '.mastersite.com' );

For more information:
http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-domain
http://www.php.net/manual/en/function.session-set-cookie-params.php
http://www.php.net/manual/en/function.session-get-cookie-params.php

Scott
I've tried to put the ini_set ( 'session.cookie_domain', '.mastersite.com' ); in the childsite program before session_start().But I dont see any changes, the the childsite couldn't read the domain session.could you explain me more detail ? thanks
adisembiring
You need to but it in the mastersite site as well, keep in mind that you have to clear the cookie before you try again as it needs to set need data in the cookie.
Scott
do you mean that I must put ini_set ( 'session.cookie_domain', '.mastersite.com' ); to the mastersite too ?
adisembiring
Yes you have to have it when the session cookie is created.
Scott
Oke scoott, I got it.Thanks for your answer. but I got some problem again. I will ask my problem in the new question
adisembiring