应该总是调用 session_start 吗?

Should session_start always be called?

我注意到我的网络服务器上有一个 tmp/ 文件夹,其中包含成千上万个会话 ID 文件。所以我认为最好只调用 session_start() 当我实际向会话(登录)中写入一些东西然后只调用它,如果有一个登录用户活动。

我找不到太多关于这个主题的东西(我什至不确定我想要完成的事情是否可能),只有几个人说 session_start() 应该总是被调用。那有意义吗?如果存储所有这些会话 ID,这不是性能问题吗?

So I thought it's probably better to only call session_start() when I am actually writing something into the session (login) and then only call it, if there's a logged in user active.

如果您以任何涉及会话的含糊传统方式设置登录系统,则在不调用 session_start.

的情况下无法判断您是否有登录用户

just a couple of people saying that session_start() should always be called. Does that make sense?

是的。如果您要与会话交互——无论是写入会话还是从中读取——然后调用 session_start().

大多数处理登录会话的网站都会在每个页面上显示“您以 Bob 身份登录:单击此处注销”或“您未登录:单击此处登录”消息,因此大多数网站将需要在每个页面上调用 sessions_start()

And isn't it a performance issue if all these session-ids are stored?

没有

它对性能有影响,但这种影响可能可以忽略不计。如果它成为一个问题,那就担心吧。

Don't try to solve performance problems you don't have.