Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel, 2 projects in 2 domains same session

I'm creating 2 projects in 2 diferent domains domain1.tld and domain2.tld.

The domain1.tld is the main event producer page and the domain2.tld is one of its events. I want to share the same sessions (they actually share the same database and the same apache server). I tried to change the session driver to "database" and create a session table, but nothing happens, if i'm log in domain1.tld nothing happens in domain2.tld.

I really have searched in the net but i have found nothing

like image 837
Snickfire Avatar asked Jan 18 '17 22:01

Snickfire


1 Answers

you can't do this in your way...

when you set session, a cookie set in browser for track stored session in server side.

if you want to share session between two domain you should share cookie between to site bot you can not do it (you can do it just in sub domains of ONE domain)

but there is a little hack : The easiest work-around is to pass login/credential information from website A to website B and have website B set a seperate cookie. For example, after logging into website A you could have them quickly redirected to website B with an encrypted querystring. Website B could then read the information, set its own cookie, and redirect the user back to site A.

It's messy but possible.

like image 82
Mahdi Youseftabar Avatar answered Sep 30 '22 03:09

Mahdi Youseftabar