[dancer-users] Mig Dancer 1 to 2: session YAML - id not in file

Peter Mottram peter at sysnix.com
Tue May 24 13:38:24 BST 2016


On 24/05/16 11:58, Jochen Schnuerle wrote:
> Hello,
>
> I use session engine YAML for my webapp ... in Dancer1 the session
> file contains:
>
> ------------------------------------------------------------------
> --- !!perl/hash:Dancer::Session::YAML
> id: 168717572663644210774823307966216571
> last: 2016.05.13-21:13:37
> logged_in: 1
> logintime: 2016.05.13-14:03:57
> role: Master
> user: fsi
> ------------------------------------------------------------------
>
> In Dancer2 the content of the session file is:
>
> ------------------------------------------------------------------
> ---
> last: 2016.05.24-10:09:09
> logged_in: 1
> logintime: 2016.05.24-08:52:31
> role: Master
> user: fsi
> ------------------------------------------------------------------
>
> I missed the id: line - but I do not know how the id come in the file.
>
> On the website for SessionFactory.pm
> (http://search.cpan.org/~xsawyerx/Dancer2-0.165000/lib/Dancer2/Core/Role/SessionFactory.pm)
> I have read, that there is a method generate_id. But I do not know how
> to use it or how I can use the retrieve method to get the id to write
> into the YAML session file.
>
> Will someone please explain?
>
> Thank you / Regards
>
>     Jochen

Hi Jochen

Dancer2::Session::YAML doesn't store the ID inside the file. You can see
the session ID by looking at the file name. For example this session file:

V0RHHQAAN6Jx2w3D4hIdDdvZCiUxXk-d.yml

corresponds to the session with id:

V0RHHQAAN6Jx2w3D4hIdDdvZCiUxXk-d

You can get the session ID within your app like this:

my $session_id = session->id;

R.
PeteM


More information about the dancer-users mailing list