Maintain subdomain sessions with Cakephp

Asked

Viewed 469 times

1

I’m having trouble keeping sessions active between system subdomains, I’m using Cakephp version 2.4.7, I’ve added the function below in App/bootstrap.php

ini_set('session.cookie_domain', env('HTTP_BASE')); 

I’ve put in the App/core.php

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

But even so it doesn’t work, has some more configuration for it to work?

  • can you put the example of Subdomain? it has which address? address to which folder?

  • take a look at this topic: http://stackoverflow.com/questions/10519570/cakephp-keep-session-from-main-domain-across-to-a-subdomain

  • Hello @Igormartins, I had already seen the link posted and it was based on it that I made the settings, but so far unsuccessful. the link is Accounts.meusite.com.br and even if you put Account.meusite.com.br pointing to the same folder does not work, on ini_set('session.cookie_domain', '.meusite.com.br'), only one Obs.: I’m working locally.

  • 1

    I had to change some settings in php.ini and following this example in the documentation (http://book.cakephp.org/1.3/pt/The-Manual/Core-Components/Sessions.html). tip! Thank you.

1 answer

2


Have a configuration within the app/Config/core.php file to change the domain session cookie:

Configure::write('Session', array(
    'defaults' => 'php',
    'ini' => array(
        'cookie_domain' => '.example.com'
    )
));

I took the test and it worked correctly.

  • I had done it before, now I don’t know if it’s because I’m using local, but it gives an infinite loop in the application.

  • I tested both local and web to ensure and worked properly. If you have version control it’s interesting to go back to the moment it worked and try to make a diff to try to understand why it didn’t work. Good luck

  • Excuse me, the loop happens in firefox when I put the above code, even using the last version, already in Chrome appears => Unable to configure the Session, Setting cookie_domain failed. = > Error: An Internal Error Has Occurred.

  • This is stranger than running naked ... tried to put on a server for testing ?

  • Rss! I will do this, I am currently using xampp, I will install everything manually and do the test on a web server. Thank you! = D

  • 1

    Another tip. i use linux for dev and testing or is help in debugging errors, if you don’t have this option use Cygwin to make Tail errors in real time, makes it much easier to develop

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.