Reputation: 3365
I use Python 3 as a serverside scripting language, and I want a way to keep users logged into my site. I don't use any framework, since I prefer to hand code pages, so how do I create session variables like in PHP in Python 3?
Upvotes: 1
Views: 4760
Reputation: 2589
The logic of a session is storing a unique session id inside the user cookie ( uuid package will do a perfect job for that ). And you store the sessions data inside a file, database or other semi-permanent datastore.
The idea is matching the sessionid that you receive from your user cookie, to some data stored somewhere on your server.
I assume that you know how to add the right header to set a cookie via the response header. Otherwise there is more information here : http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Responses
Upvotes: 4