sessions and subdomains
Hello,
I'm having trouble to setup one session that will work for subdomains
and the main domain... I've read a lot about using various ways like
init_set() or set.cookie_domain or using .htaccess and some others I
can't remember... Everyone posting examples on the net are people who
are having trouble with this session subdomain thing and I've tried
some solutions but they don't seem to work. Please suggest something
without having to access php.ini... and the same problem goes for
cookies... but I guess if I can figure out sessions then cookies will
be ok.. thanks
Simon
Re: sessions and subdomains
..oO(Kentor)
>I'm having trouble to setup one session that will work for subdomains
>and the main domain... I've read a lot about using various ways like
>init_set() or set.cookie_domain or using .htaccess and some others I
>can't remember... Everyone posting examples on the net are people who
>are having trouble with this session subdomain thing and I've tried
>some solutions but they don't seem to work.
What have you tried so far? According to the manual it should be quite
easy. Setting the cookie domain to something like example.com instead of
www.example.com should make it available for the entire domain including
subdomains, so you can access the session from there as well as from the
main domain.
Micha
Re: sessions and subdomains
On 11 May, 04:55, Kentor <ken... [at] gmail.com> wrote:
> Hello,
>
> I'm having trouble to setup one session that will work for subdomains
> and the main domain... I've read a lot about using various ways like
> init_set() or set.cookie_domain or using .htaccess and some others I
> can't remember... Everyone posting examples on the net are people who
> are having trouble with this session subdomain thing and I've tried
> some solutions but they don't seem to work. Please suggest something
> without having to access php.ini... and the same problem goes for
> cookies... but I guess if I can figure out sessions then cookies will
> be ok.. thanks
>
> Simon
$expiry = time()+900;
$path = '/';
$domain = server.com
session_start();
setcookie(session_name(),session_id(), $expiry, $path,$domain);
this way you are in control of what domain is used for the cookie
which in turn is used to send the session identifier, if you use the
more restrictive subdomain (as michael said) then the session id
cannot be accessed from the other sub domains on your server, unless
you take steps to write your own session-data-pass-along code, but the
above is easier huh!
Re: sessions and subdomains
On 11 May, 04:55, Kentor <ken... [at] gmail.com> wrote:
> Hello,
>
> I'm having trouble to setup one session that will work for subdomains
> and the main domain... I've read a lot about using various ways like
> init_set() or set.cookie_domain or using .htaccess and some others I
> can't remember... Everyone posting examples on the net are people who
> are having trouble with this session subdomain thing and I've tried
> some solutions but they don't seem to work. Please suggest something
> without having to access php.ini... and the same problem goes for
> cookies... but I guess if I can figure out sessions then cookies will
> be ok.. thanks
>
> Simon
sorry for typo
$domain = 'server.com';