I have two web2py apps that share the same db, and they also share the session.
Both apps are served through different domains (using routes.py).
That means that the user logs in one domain (through one of the apps), and then can navigate through both domains (that is, both apps) being logged in.
I've achieved that with this code in models/db.py:
db = DAL(...)
session.connect(request, response, db=db, masterapp='primary')
if response.session_id_name in response.cookies:
response.cookies[response.session_id_name]['domain'] = 'primarydomain.com'
Please notice the last two lines of code. I had to add those two lines in order for it to work.
It wasn't enough setting masterapp='primary', the session wasn't shared through apps (and both domains), so then I managed to make that fix.
However, I'm not so sure if that's the correct way of doing it.
The reason I'm not sure is because some times (very few times), the browser gets stuck asking for login.
I cannot reproduce the problem, but in some rare ocasions, the user cannot login anymore (the browser keeps asking email and password, and the user needs to delete all cookies in order to login again).
If you consider that isn't the proper way of doing it, I will appreciate any suggestion or comment.
Thanks as always!
Regards,
Lisandro.