I'm quite new to web2py and a noob at it. I've been struggling with the 
difference between cookies and sessions. For what I've read the main 
difference is that you store cookies on the clients side and sessions on 
the server side, also that cookies expire and sessions get erased when you 
close the browser! But I have plenty of questions about them and how to use 
them(in web2py)

*1. What can you store in them? *
                *I've seen till now that you can store a dict and lists in 
a session, and I'm having trouble using cookies but I guess text is the 
only thing you can store...  *
*
*
*2. When are they deleted?*
               *According to what I googled cookies expire after a certain 
time(I've seen you can set this in w2p) and sessions are deleted when you 
exit the browser*
*
*
*3. Could you use cookies as temporary DB?*
*                **If I'm right and can only store text I guess this would 
be complicated, but then the question is if you can modify the expiring 
time so it never expires unless the user deletes it? *
*                    I mean you could use it to store user statistics for 
example? This is one of the things I want to implement but having trouble 
doing it. Let me show you what I'm trying *
*
*
*I first do this **                                
def cookieCreate():
    
    response.cookies['cookie_test'] = 1
    response.cookies['cookie_test']['expires'] = 24 * 3600
    response.cookies['cookie_test']['path'] = '/'
then*
*
 if request.cookies.has_key('cookie_test'):
            value = request.cookies['cookie_test'].value
            response.cookies['cookie_prueba'] = str( 1 + int(value)) 
#Shouldn't this update the cookie on the clients side?
        else: 
            cookieCreate()
As you can see, I want to implement a sort of counter that doesn't get 
deleted to develop some statistics later(how many games he played for 
example), and don't want to have a DB yet ( I want to learn how to work 
with cookies)*
*
*
*4. Where are they stored?*
*               **  I imagine cookies are stored where the browser decides, 
then why the "path"? and while session exists where are they stored?*
*
*
*5. Can you store a cookie in a session and viceversa?*
*
*
*6. If sessions have to somehow be stored at the server how do you know 
which one belongs to whom? Is the a unique id? *
*
*
*
*
Well thank you in advance to whoever can help me, I just discovered 
yesterday there was this group!
*
*

*              * 

Reply via email to