Hi All,
I looked through the posts in group and didn't find any suitable solution
for my query so I am posting it.
This is how I am creating session in my app:
web.config.debug=False
web.config.session_parameters['cookie_name'] = 'webpy_session_id'
web.config.session_parameters['cookie_domain'] = '/'
web.config.session_parameters['timeout'] = 86400, #24 * 60 * 60, # 24 hours
in seconds
web.config.session_parameters['ignore_expiry'] = True
web.config.session_parameters['ignore_change_ip'] = True
web.config.session_parameters['secret_key'] = 'fLjUfxqXtfNoIldA0A0J'
web.config.session_parameters['expired_message'] = 'Session expired'
store=web.session.DiskStore('sessions')
if web.config.get('_session') is None:
session = web.session.Session(app, store,
initializer={'username':'Guest','userId':'Guest','loggedIn':False})
web.config._session = session
else:
session = web.config._session
render = web.template.render('templates/', base='main',
globals={'session':session})
And this how I have implemented login into my system:
class Login:
def POST(self):
sFormData = web.input()
url="<my app api>"
response = urllib2.urlopen(url)
user=json.load(response)
if user['available']:
session.username=user['username']
session.userId=user['userid']
session.loggedIn=True
print "returning json dump"
print "Session username in login---->", session.username
print "Session loggedIn in login---->", session.loggedIn
print "Session userId in login---->", session.userId
return json.dumps(user)
As you can see, the above controller returns a JSON which is then consumed
in javascript and then app is updated accordingly. This is WIP. What my
concern is that session is not getting saved. I dont want to store session
in a DB.... what is currently happening in now that when I refresh page, my
session data is lost. I am passing session as global in template so that I
can access session data in my template. I tried every possible solution
available. I am frankly unable to detect where I am going wrong in this.
Please provide some help.
Regards,
Partho
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.