在pyramid中使用 session

访问量: 799

1. in the __init__.py

from pyramid.config import Configurator
from pyramid.session import UnencryptedCookieSessionFactoryConfig
def main(global_config, **settings):
    my_session_factory = UnencryptedCookieSessionFactoryConfig('m-app-ms')
    config = Configurator(settings=settings, session_factory = my_session_factory)

2. 使用: (in the view.py file)

def foo
    session = request.session
    session['abc']= 'abc'
    print session['abc']

订阅/RSS Feed

Subscribe

分类/category