1

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...

PayteR
  • 1,727
  • 1
  • 19
  • 35

3 Answers3

1

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

PayteR
  • 1,727
  • 1
  • 19
  • 35
0

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") ;

FMaz008
  • 11,161
  • 19
  • 68
  • 100
  • sorry but like i said "I have setted all successfully right" with this included, and must be ini_set("session.cookie_domain",".domain.com"); for correction, like i said, it works in pure php, but no in phpcake with same configuration... so thanks for reply, but this is not right answer – PayteR Sep 24 '11 at 09:00
0

Try using this instead:

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

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

Ivo
  • 5,378
  • 2
  • 18
  • 18