PayteR
PayteR

Reputation: 1757

PHP cake subdomains session link problem?

i have problem with php cake session and subdomains. I have setted all successfully right. When i try to go from

subdomain1.domain.com 

to

subdomain2.domain.com 

all works nicely when i put these browser url... problem comes when i try to make this with <a href=""> tag, on redirected subdomain i will recieve new session id.

I cant explain to my self how can be this possible, pure php script works fine but in php cake is this bug! thanks for any suggestion...

Upvotes: 1

Views: 469

Answers (3)

PayteR
PayteR

Reputation: 1757

ok, i debug whole php cake session component and lib, i figure out 2 sollutions

  1. easier - set in core.php security level to low

    Configure::write('Security.level', 'low');

  2. advanced - make new config file for sessions, like Ivo said, its in tutorial http://book.cakephp.org/view/1310/Sessions ,most important thing is set

    ini_restore('session.referer_check'); because by default php cake check referrer, and if it goes not form same domain it will cause generating new SESSIONID

Upvotes: 1

Ivo
Ivo

Reputation: 5420

Try using this instead:

http://book.cakephp.org/view/1310/Sessions

Follow the directions to create custom configuration for cake's session saving.

Upvotes: 0

FMaz008
FMaz008

Reputation: 11295

I don't think it's related with cake. By default, PHP will give you a session for the domain.

  • subdomain1.domain.com is a domain,
  • subdomain2.domain.com is another domain
  • domain.com is another different domain
  • www.domain.com is another different domain

All thoses examples are 4 distincts domains, with their own session.

If you want to share the session between many (sub)domain, you can try to set the session.cookie_domain variable, like this;

ini_set("session.cookie_domain","domain.com") ;

Upvotes: 0

Related Questions