The problem that Session variables have to overcome is that the HTTP
protocol that you use to browse the web is stateless. Each request for a
page is completely independant of earlier requests, so if you want  to
"remember" the variables you have to store that information somewhere. This
remembering of user-specific data is called "maintaining state".

Session lives until browser is openned to keep the session relation with the
cookie that stores the session ID,
if you want to mantain  session variables active for a long time, you have
to create a cookie, specify the cookie duration, insert your values to the
cookie and also check if the cookie exists on every page load.

You can save the information in a database as explained here:
http://web2py.com/book/default/chapter/04?search=session#session

also you have to save a cookie that refers to that register in database, or
if you want, you can save the whoke information in the cookie.

I dont know any other trick to maintain state with web2py, anybody?



2010/8/5 Cody <[email protected]>

> Hello,
>
> I just started using web2py this summer to create a website.
>
> Currently, I am having an issue with sessions. I am trying to store
> information in session variables without having the user login, but
> whenever the browser closes and reopens all the session variables are
> reset. I am only storing strings and integers, and the code works as
> long as the browser does not close.
>
> Is there anyway to prevent this? Also, how long do sessions last, and
> how can I change that?




-- 

http://rochacbruno.com.br

Reply via email to