Sharing CakePHP session with another app

This question pops up once in a while: “How do I share session data with a third-party application?”

Thankfully the answer is pretty simple, just make sure that the session (cookie) name is the same for both apps.
In CakePHP it’s set in the core.php… Configure::write(‘Session.cookie’, ‘CAKEPHP’);

13 thoughts on “Sharing CakePHP session with another app

  1. hi, i want to know whether a cake app and a non cake subdomain app can work well if cake app is and non cake part is Is it possible? What precuations are needed to take to make both work well?
    The subdomain app will use same database as used by cake app on main domain.

  2. @kiran

    I’ve never actually tested this situation, so I cannot give you an accurate answer. Please take a look at the post above by primeminister. I think it covers what you are looking to do…
    Also double check at the google group, I’m sure someone there might have a specific answer.

  3. my folder structure

    if I create a session with $this->Session->write(‘User’,$user); in main site and redirect it to child site, my session data is not being accessed. I am not getting User data with $this->Session->read(‘User’) in child site.

    Can anybody help me ?

  4. @Chirayu

    pr($_SESSION); what do you see?
    It seems like you are on shared host and sometimes they have all sorts of strange security features in-place that could possibly cause some problems there. Hard to guess.

  5. Hi tekno, here is the session values.
    Array ( [Config] => Array ( [userAgent] => bc2b15193fd333c5666514e9cb360c36 [time] => 1236369514 [rand] => 1001972704 [timeout] => 10 ) )

  6. Well, I am not shared host but I have created subdomain on my local webserver with
    DocumentRoot /var/www/html/caken
    ServerName caken

    DocumentRoot /var/www/html/chirayu
    ServerName chirayu

  7. @Chirayu

    Did you read the comment posted by primeminister? Seems like it might address your issue, other than that I, unfortunately, don’t really have another suggestion. Maybe someone on IRC or the google group can provide an answer.

  8. Hello
    My folder structure

    Here blog is wordpress blog. I want to find session value from app to blog

    any body help me please

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s