Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jbandara1988's avatar

Sharing session with Laravel 5.1 and Laravel 5.5 app

Hi, I'm trying to share sessions between Laravel 5.5 app and a Laravel 5.1 app. I configured sessions configurations of Laravel 5.5 app to 5.1 app (since 5.1 app is the master app). I'm sharing the same domain and structure is as follows, www.<5.1 app>.com/<5.5 app name>

I was able to see sessions in 5.5 app when I set sessions in 5.1 app . But the problem is I cannot seems to share Auth users across these two apps. I understand there are few different changes in Authenticating methods for an example in 5.5 app it looks for the session key like login_web_xxx wherein 5.1 app it looks for login_xxxx.

I suppose if I change that session key, I might be able to access 5.1 user data. In 5.5 it uses following method to get the session key for the user (SessionGuard line 616)

 /**
     * Get a unique identifier for the auth session value.
     *
     * @return string
     */
    public function getName()
    {
        return 'login_'.$this->name.'_'.sha1(static::class);
    }

Can anyone suggest me what the logic it has used to get the session key in Laravel 5.1 app?

Thank you.

0 likes
2 replies
bobbybouwmann's avatar

I think it's possible when you use one as a the main domain and the other as a subdomain. From there you should set the config/session.php and assign the following value to the domain key

'domain' => env('SESSION_DOMAIN', '.yourdomain.com'),

Notice the . in front of the domain. Of course you can set that value in the .env as well ;)

ArjenNZ's avatar

Make sure the APP_KEY in your .env is the same as the other project.

Please or to participate in this conversation.