0

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 ?

Adi Sembiring
  • 5,798
  • 12
  • 58
  • 70
  • may help http://stackoverflow.com/questions/348282/php-cookie-domain-subdomain-control . or this link http://content.websitegear.com/article/subdomain_tips.htm – Haim Evgi Jan 12 '10 at 14:50

1 Answers1

3

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
  • 3,290
  • 4
  • 29
  • 48
  • 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 – Adi Sembiring Jan 12 '10 at 16:58
  • 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 Jan 12 '10 at 18:14
  • do you mean that I must put ini_set ( 'session.cookie_domain', '.mastersite.com' ); to the mastersite too ? – Adi Sembiring Jan 12 '10 at 22:53
  • Yes you have to have it when the session cookie is created. – Scott Jan 12 '10 at 23:18
  • Oke scoott, I got it. Thanks for your answer. but I got some problem again. I will ask my problem in the new question – Adi Sembiring Jan 13 '10 at 00:02