If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!
If you still did not have made a single login for your applications, and wish to, you can access this slice first. If you have already made the single login, just keep going all the way down on this post.
 
You may have noticed that when you share a database between applications, they will use the same record. So the user will be able to make login on all of the applications even if he had registered only once. But this do not guarantee that if he changes between the applications, he will continue logged (I guarantee he will not). That's why we need to share the applications' sessions too. Because this way he will continue logged (I guarantee too).

All this process of sharing sessions is a very very very very difficult one. So, let just start by writing this right after the database connection on the Main application db.py file:

#this is the database connection
auth_db = DAL('sqlite://users.sqlite')
#this is the line you should add:
session.connect(request, response, tablename='sessions')

It will make the sessions to be recorded on a table on your database that the Other application will access. Now copy the line on the db.py file of the Other application with just a few changes:

auth_db = DAL('sqlite://users.sqlite', folder='/home/yourname/web2py/applications/main/databases/')
session.connect(request, response, masterapp = 'main')

What masterapp says to you is "Wich application should I "steal" the sessions?". Then you say to it "Please, steal the Main application sessions and everything will be fine".

And the very very very very difficult process ends here. I hope I didn't make you suffer, but it's over now. Go home and relax.

Related slices

Comments (1)


Hosting graciously provided by:
Python Anywhere