Flask会话未持续

2024-06-09 00:16:47 发布

您现在位置:Python中文网/ 问答频道 /正文

Am在CentOS 6.3上运行Python2.7、Apache+mod_wsgi

当我在本地主机上时,一切正常。但是,当我在Azure中的vm上运行代码时,我看不到跨页面持久化的会话信息。

基本上在我看来,我有这样的想法:

@frontend.route('/')
def index():
   session['foo'] = 'bar'
   print session['foo']

   return redirect(url_for("frontend.page2"))

@frontend.route('page2')
def page2():
   print session

打印输出为:

bar
<SecureCookieSession {}>

我对apache的wsgi配置是:

WSGISocketPrefix /var/run/wsgi

<VirtualHost *:80>
    ServerName example.com
    ServerAlias example.com

    WSGIDaemonProcess myproj threads=5 processes=5
    WSGIScriptAlias / /home/mydir/myproj/apache/myproj.wsgi

    <Directory /home/mydir/myproj>
        WSGIScriptReloading On
        WSGIProcessGroup myproj
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

我有一套秘钥:

app.secret_key = os.urandom(24)

我尝试过两种设置服务器名称,但都没有帮助:

app.config['SERVER_NAME'] = 'example.com' 

有什么办法可以再调试一下吗?

谢谢!


Tags: comwsgihomefooexamplesessionapachedef