Smarty kills my session

2019-08-15 18:49发布

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?

2条回答
一纸荒年 Trace。
2楼-- · 2019-08-15 19:01

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')

查看更多
姐就是有狂的资本
3楼-- · 2019-08-15 19:02

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.

查看更多
登录 后发表回答