Skip to main content

No project description provided

Project description

Muffin-Session – Implement an user sessions in Muffin Framework.

Build Status


  • python >= 3.3


Muffin-Session should be installed using pip:

pip install muffin-session


  • Add muffin_session to PLUGINS in your Application configuration.
  • Setup options if needed (see bellow).


SESSION_AUTO_LOAD – Load session every request automatically Session will be loaded into request.session.

SESSION_DEFAULT_USER_CHECKER – A function which checks logged user (lambda x: x)

SESSION_LOGIN_URL – Redirect URL (‘/login’), or it may be a function which accepts request object and returns a string.

SESSION_SECRET – A secret code (‘Insecuresecret’)

SESSION_MAX_AGE – # Defines the lifetime of the session-cookie, in seconds

SESSION_DOMAIN – # Defines session-cookie domain

def load_user(_id):
    """Define your own user loader. """

def get_session(request):
    """ Load session and return it as JSON. """
    session = yield from
    return dict(session)

@app.register('/admin') u: u.is_admin)
def admin(request):
    """ Check for user is admin. """

def login(request):
    """ Login user. """
    # ...
    yield from

def logout(request):
    """ Logout user. """
    # ...
    yield from

def somewhere(request):
    """ Do something and leave a flash message """
    # ...
    yield from'Something done successfully')

def common_page(request):
    This can be included in any endpoint which outputs regular page.
    If you use jinja2 or other templating engine,
    you will need to pass `request` to its context somehow.
    Also this plugin will register `get_flashed_messages` function in Jinja2 context,
    but only if Jinja2 plugin was loaded before this one.
    # first we want to ensure that session is loaded,
    yield from
    # this method is *not* a coroutine, so it can be used in templates
    messages =
    return (
        "<html><body><header>%s</header> Other content </body></html>" %

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at


Development of Muffin-Session happens at:


  • klen (Kirill Klenov)


Licensed under a MIT license.

If you wish to express your appreciation for the project, you are welcome to send a postcard to:

Kirill Klenov
pos. Severny 8-3
MO, Istra, 143500

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
muffin_session-0.6.2-py2.py3-none-any.whl (6.3 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Nov 13, 2018
muffin-session-0.6.2.tar.gz (6.5 kB) Copy SHA256 hash SHA256 Source None Nov 13, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page