Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:11:58+00:00 2026-06-03T05:11:58+00:00

I’m writing an app using bottle.py and beaker.middleware.SessionMiddleware : How can I modify the

  • 0

I’m writing an app using bottle.py and beaker.middleware.SessionMiddleware:

How can I modify the session.timeout and session.cookie_expires values so I can implement a login system that logs the user in for 30 days?

I already implemented the standard login system so everything works until the browser closes, but I’d like to modify those values if the user checks the Remember me checkbox.

I thought of two variants if the user checks the Remember me checkbox:

  • Set session.cookie_expires and session.timeout to 30 days, but it seems that I can’t modify these values at run-time because the cookie I recieve expires at the end of the browser session, ignoring my runtime modifications.

  • Set session.timeout to 30 days and overwrite the cookie named beaker.session.id writing the same session id but different expiry date.
    But the run-time problem from point 1. remains and it seems that I can’t access the session’s id that I just created with beaker, so I don’t know what to store in the cookie.

How can I implement this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:11:59+00:00Added an answer on June 3, 2026 at 5:11 am

    The only solution I come up with is to implement my own little backend and setting cookies myself, without beaker.

    For posterity’s sake, the code is here:
    https://github.com/paulbarbu/bottle-upload/blob/master/index.py
    Methods: login_bl, upload_view(db), is_logged_in, and logout().
    Please note this is some VERY old code and NOT production ready, use at your own risk, some code snippets from the above link follow:

    Login:

    @post('/login')
    def login_bl(db):
    import hashlib
    
    nick = request.forms.nick.lower()
    password = hashlib.sha1(request.forms.password).hexdigest()
    
    message = {}
    error = None
    
    uid  = get_user_id(db, nick, password)
    
    if uid:
        sess = request.environ.get('beaker.session')
        sess['uid'] = uid
        # .... do other stuff for the logged in user
    

    Logout:

    @get('/logout')
    def logout():
    if not is_logged_in():
        redirect('/login')
    else:
        sess = request.environ.get('beaker.session')
        sess.delete()
    
    return template('logout.tpl')
    

    Is the user logged in?

    def is_logged_in():
    '''Check whether the user sent a cookie that holds a Beaker created
    session id
    '''
    
    sess_id = request.cookies.get('beaker.session.id', False)
    
    if not sess_id:
        return False
    
    sess = request.environ.get('beaker.session')
    
    if 'uid' not in sess:
        return False
    
    return True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.