Browse files

explain DBStore

  • Loading branch information...
1 parent 7a67ef2 commit cd4b33178b96d04f88d76e1869a060b1d3759790 @anandology anandology committed with anandology Jun 25, 2008
Showing with 12 additions and 0 deletions.
  1. +12 −0 cookbook/
@@ -38,4 +38,16 @@ The session object is loaded with the session data before handling the request a
The optional `initializer` argument to Session specifies the initial session.
+You can use `DBStore` instead of `DiskStore` if you prefer to store sessions in database instead of disk. For using DBStore you need to have a table with the following schema.
+ create table sessions (
+ session_id char(128) UNIQUE NOT NULL,
+ atime datetime NOT NULL default current_timestamp,
+ data text
+ );
+And you need to pass `db` object and session table name to the constructor of `DBStore`.
+ db = web.database(dbn='postgres', db='mydatabase', user='myname', pw='')
+ store = DBStore(db, 'sessions')
+ session = web.session.Session(app, store, initializer={'count': 0})

0 comments on commit cd4b331

Please sign in to comment.