简体   繁体   English

Nette 框架 - 获取当前会话 ID

[英]Nette Framework - Get Current Session ID

I need to get an ID of current session .我需要获取当前 sessionID Using httpRequest's cookies is not a good idea because session gets regenerated after login or by whatever action.使用 httpRequest 的 cookie 不是一个好主意,因为登录后或通过任何操作都会重新生成会话。

I also tried Session class but for getting a session ID it is needed to specify a section which Nette uses to split the application.我也尝试过 Session 类,但是为了获取会话 ID,需要指定 Nette 用来拆分应用程序的部分。 However I couldn't find out the section name.但是我找不到部分名称。

演示者中有方法getSession()可用,因此要访问会话 ID,您可以使用:

$sessionId = $this->getSession()->getId();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM