Smarty kills my session

百般思念 提交于 2019-12-13 19:11:58

问题


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:

  1. When you write templates in extending way (one template extends other), you can't see Smarty debug window, even if $smaty->debug=true

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!