Sessions in regard to domain - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Sessions in regard to domain

CveleCvele Posts: 96Member
Hi!

I got following problem.
My PHP session is not the same for [b]mysite.com[/b] and [b]www.mysite.com[/b]. Ie, when user logs in to [b]www.mysite.com[/b], he is not automatically logged in to [b]mysite.com[/b] and vice-versa.

I've tried using following code without any success:
[hr]
[italic]session_set_cookie_params(0 , '/', '.mysite.com');
session_start();[/italic]
[hr]

... as well as:
[hr]
[italic]ini_set('session.cookie_domain', '.mysite.com');
session_start();[/italic]
[hr]

... and as well as:
[hr]
[italic]ini_set('session.cookie_domain', (strpos($_SERVER['HTTP_HOST'],'.') !== false) ? $_SERVER['HTTP_HOST'] : '');
session_start();[/italic]
[hr]

So, after trying to convince my host company to deal with this in [italic]php.ini[/italic], I am left without options known to me.

How do I deal with this?
Sign In or Register to comment.