Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i update expire time per call or refresh page #233

Open
rikhtehgaran opened this issue Dec 20, 2023 · 0 comments
Open

How can i update expire time per call or refresh page #233

rikhtehgaran opened this issue Dec 20, 2023 · 0 comments

Comments

@rikhtehgaran
Copy link

Hi I have been using the beaker in Bottle framework but I don't know how to update the session cookie expiration time in a beaker
it's my code. I need to update the expiration time in the test method when called

import bottle
from beaker.middleware import SessionMiddleware

session_opts = {
    'session.type': 'file',
    'session.cookie_expires': 300,
    'session.data_dir': './data',
    'session.auto': True,

}
app = bottle.Bottle()
subapp = SessionMiddleware(app, session_opts,environ_key="myapp")

@app.route('/test')
def test():
  s = bottle.request.environ.get('myapp')
  subapp.options={'session.cookie_expires': 300}
  s['test'] = s.get('test',0) + 1
  s.save()
  return 'Test counter: %d' % s['test']

bottle.run(app=subapp, port=8000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant