Skip to content

Alternative for Flask session module that uses MongoDB as main storage

License

Notifications You must be signed in to change notification settings

bayazee/flask-mosession

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flask-mosession

Alternative for Flask session module that uses MongoDB as main storage

Easy to setup and use

Here is an example showing how to setup and use flask-mosession:

from datetime import datetime
from flask import Flask, session
from flask.ext.mosession import MoSessionExtension

app = Flask(__name__)

app.config['MONGODB_HOST'] = '127.0.0.1'
app.config['MONGODB_PORT'] = 27017
app.config['MONGODB_DATABASE'] = 'session_test_db'
mosession = MoSessionExtension(app)


@app.route("/")
def hello():
    if 'first_visit' not in session:
        session['first_visit'] = datetime.now()

    return 'Hi dear, your first visit was on ' + str(session['first_visit'])


if __name__ == '__main__':
    app.run()

About

Alternative for Flask session module that uses MongoDB as main storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages