问题
I have a problem with Smarty 3.1.13.
Smarty kills my session. Every time I refresh my page, $_SESSION array is empty.
When I comment line $smarty->display('index.tpl')
, everything is OK.
Any ideas?
回答1:
You have to start your session before $smarty->display('index.tpl')
This is beacause the session cookie needs to be send in the HTTP header and therefore session_start will need to be called before the first line of output.
So make sure session_start()
is placed before $smarty->display('index.tpl')
回答2:
I can't post this time code, because it's divided to many parts (framework), and I don't have permissions to publish them. Thanks for your time, but I found another problem with Smarty and solusion for my problem:
When you write templates in extending way (one template extends other), you can't see Smarty debug window, even if
$smaty->debug=true
When your running template is extending another, and
$smarty->debug = true
, it kills your session. Don't ask me why, I didn't have time to check it. I think it's a bug.
来源:https://stackoverflow.com/questions/14377923/smarty-kills-my-session