Search code examples
phpsessioncookiessession-cookiesnette

Nette Framework - Get Current Session ID


I need to get an ID of current session. Using httpRequest's cookies is not a good idea because session gets regenerated after login or by whatever action.

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. However I couldn't find out the section name.


Solution

  • There's method getSession() available in a presenter, so for accessing the session ID you can use:

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