I tried to store and reload the session the following way
in db.py i added
import pickle
#--------------------------
def session_load(form = None):
    global session
    auth_session = db(db.auth_session.user ==
auth.user.id).select().first()
    session = pickle.loads(auth_session.session)
def session_save():
    if auth.is_logged_in():
        auth_session = db(db.auth_session.user ==
auth.user.id).select().first()
        if not auth_session: db.auth_session.insert(user =
auth.user.id, session = pickle.dumps(session))
        else: auth_session.update_record(session =
pickle.dumps(session))
#--------------------------
auth=Auth(globals(),db)                      # authentication/
authorization
auth.settings.login_onaccept = session_load

saving works fine but loading the session does not work
whenever I load it the contents of the loaded session is lost, why?

On Apr 20, 9:44 am, selecta <gr...@delarue-berlin.de> wrote:
> well kind of ... the users should get their "old" customization back
> once they are logged in
> this is the easy part, I just have to load the pickledsessionfrom
> the db (I guess), but my question is how to store it properly
> if I store thesessioninformation on logout is not enough
> I would like to store it as soon as data is written to thesession
> object, but I am not sure how to overwrite thesessionobject for that
> I see a _try_store_in_db() and _try_store_on_disk() in thesession
> object, are these function called when thesessionvariables change?
>
> I guess this would be a nice addition to thesessionobject in general
> e.g.session.auth_presist
> everything that is written to the auth_presist object of thesession
> will be stored in the auth_user table along with the user information
> and whenever the user logges in the auth_presist object is recovered
>
> On Apr 19, 4:31 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>
>
>
> > Or have a "settings" table that is linked by user id? They only get
> > the site customizations if they are logged in?
>
> > --
> > Thadeus
>
> > On Mon, Apr 19, 2010 at 8:01 AM, selecta <gr...@delarue-berlin.de> wrote:
> > > that should work
>
> > > On Apr 19, 1:06 pm, Jason Brower <encomp...@gmail.com> wrote:
> > >> On the same lines, I wonder if someone could simply pickle everything is
> > >>sessionand save it in teh database under there user id.
> > >> BR,
> > >> Jason
>
> > >> On Mon, 2010-04-19 at 03:18 -0700, selecta wrote:
> > >> > I wonder what is the best way to storesessionof auth users
>
> > >> > What I want is to retrieve an oldsessionof a user when he loges in
> > >> > again (restoring all his customizations etc)
> > >> > To achieve this I could
> > >> > A) store thesessionin a table once the user loges out, but then I
> > >> > would loose changes if thesessionjust expires because the user never
> > >> > logged out (right?)
> > >> > B) I could modify thesessionobject to save itself in the database as
> > >> > soon as it is changed
>
> > >> > B) sounds nicer, but how to do that, maybe somebody already did that?
> > >> > some help would be nice
>
> > >> --
> > >> Subscription 
> > >> settings:http://groups.google.com/group/web2py/subscribe?hl=en

Reply via email to