Search code examples
pythonsession-cookiescherrypy

How to stop regenerating cherrpy.session.id for each call


Folks,

I am running one instance of CherryPy (Version 3.2.4) server and for same endpoint, I am printing value of cherrypy.request.cookie and cherrypy.session.id. for 4 subsequent calls:

 session_id=ed46544a403a633bc632a9d193a722a6e0cc9088 b0bb3aec2a5858cbd69e0d3933d2852e753725cd
 session_id=b0bb3aec2a5858cbd69e0d3933d2852e753725cd 069564740a1f38fdc8f4721ee759c3ff1f2a12d2
 session_id=069564740a1f38fdc8f4721ee759c3ff1f2a12d2 87cd7af0bd36ec9d9d4b6e6d74f28fb138ddacfc
 session_id=87cd7af0bd36ec9d9d4b6e6d74f28fb138ddacfc 8cbabaa63f09ce601611c4e7d7f9b28522f4d76f

If you see each subsequent calls, cherrypy.session.id gets regerated and sent to client, which comes in next request as cherrypy.request.cookie. It means, each time, I am generating a new session id? What option can I use to stop that?

For same user, I want to have same session_id as long as he does not clears his browser cache?

Please help.

EDIT: This is what my config looks like:

cherrypy.config.update({                 
    'tools.sessions.on':            True,
    'tools.sessions.timeout':       120  
})                                       

Solution

  • cherrypy.session['any_string'] = 'some_string' means that saving any data in session does the trick.