Re: Basics about passing variable to the user's session
Stephan Semerad <[email protected]> Tue, 6 Jun 2017 14:07:24 -0700 (PDT)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
cherrypy.session['email'] = 'email'
email = cherrypy.session['email']
or here the working example
import cherrypy
class app():
@cherrypy.expose
def set_session(self, email = "[email protected]"):
cherrypy.session["email"] = email
return email
@cherrypy.expose
def get_session(self):
return cherrypy.session['email']
cherrypy.quickstart(app(), "/", {
"/": {
"tools.sessions.on": True,
}
})
On Sunday, January 8, 2017 at 11:42:28 PM UTC+1, Germán Rimoldi wrote:
>
> Hi Guys!
>
>
> I need help passing variable to the user's session and calling this from a
> different function: Could you help me out with this?
>
>
> First, I would like ot "set" a variable on the user's session.
>
>
> @cherrypy.exposedef setter(self):
> email = "[email protected] <javascript:>"
> cherrypy.session["email"] = email
> return "Variable passed to session"
>
>
> Second, I would like to call that variable from the session on a different
> function.
>
> @cherrypy.exposedef getter(self):
> return cherrypy.session.get("email")
>
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.