0

I have one domain and sub domain as bellow,

domain-name.local
sub.domain-name.local

I have a login system in domain-name.local and I need to use same sessions to validate while accessing sub.domain-name.local.

As mention in the question I have tried following things in sub domain without success,


Set php.ini session.cookie_domain as .domain-name.local

Results :

firefox- worked ie- not loading while accessing the session from sub domain chrome - not giving any session details


set from php code as bellow

    ini_set('session.cookie_domain', '.domain-name.local');
    session_start();
    var_dump($_SESSION);

Results :

firefox - not giving any session details , ie- not loading while accessing the session from sub domain, chrome - not giving any session details


another php code as suggest in that question,

    session_set_cookie_params(0, '/', '.domain-name.local');
    session_start();
    var_dump($_SESSION);

Results : same as second


Any help would be appreciate since i'm stuck here for long time.


EDIT :

When I checked the cookies, I can see two PHPSESSID was created. I think that is the issue. I need to use the same PHPSESSID from the main.


EDIT 2

When I set the session.cookie_domain to .domain-name.local from the php.ini or .htaccess, everything is working fine except in the IE(ie 10/win 8). In IE sometimes session can access sometime web page totally not accessible(keep loading but no result for minutes).

Does anyone was having same experience on the same issue.

Community
  • 1
  • 1
Janith Chinthana
  • 3,792
  • 2
  • 27
  • 54
  • please read the `EDIT 2`, I follow that question as well, but here issue is different, it's working except `IE`. – Janith Chinthana May 15 '14 at 05:57
  • I clearly mention in `EDIT 2` that I'm facing some other issue which is not address in duplicate question. But still this is mark as duplicate which is not acceptable. Please reconsider. – Janith Chinthana May 15 '14 at 12:18

2 Answers2

0

You should try to regenerate the session id:

session_regenerate_id(true);
Arko Elsenaar
  • 1,689
  • 3
  • 18
  • 33
0

if session handining work not well, you can write your own via session_set_save_handler(...)

but you need this

@setcookie(
   session_name(),
   session_id(),
   1400069742, // time + TTL
   '/',
   '.domain-name.local',
   false,
   false // use false if you need cookie accessable from javascript
  );
user5332
  • 758
  • 2
  • 9
  • 17