[dancer-users] Dancer2 session file not being created.

Stefan Hornburg (Racke) racke at linuxia.de
Mon Apr 4 08:46:38 BST 2016


On 04/03/2016 10:12 PM, vijayvithal jahagirdar wrote:
> 
> 0down votefavorite <http://stackoverflow.com/questions/36377451/dancer2-session-not-written-to-file?noredirect=1#>
> 	
> 
> In my Dancer2 app I find that the session information is not stored in between file request. I am using YAML as my session store format.
> 
> e.g.
> 
> I have defined a test route to set a variable in the session and dump the settings and session variable in the template using Data Dumper in the template.
> 
> 
> get '/test/:key/:value'=>sub{my$key =params->{key};my$value =params->{value};session($key=>$value);template 'test';};
> 
> The result of Data Dumper is
> 
> |$VAR1 ={'engines'=>{'template'=>{'template_toolkit'=>{'start_tag'=>'<%','end_tag'=>'%>'}},'session'=>{'YAML'=>{'cookie_name'=>'domain.session','is_secure'=>'1','is_http_only'=>'1','session_dir'=>'/tmp/dancer-sessions/'}}},|
> 
> And session var is
> 
> |$VAR1 ={'a'=>1};|
> 
> At this point I expect my /tmp directory to contain a session folder but I see the following
> 
> |starman at ubuntu:~/www/app$ ls -al /tmp total 776drwxrwxrwt 2root root 4096Apr214:39.drwxr-xr-x 21root root 4096Apr207:31..-rw-r--r--1starman starman 776737Apr214:31starman.err -rw-r--r--1starman starman 0Apr207:31starman.out -rw-r--r--1starman starman 4Apr214:31starman.pid|
> 
> I am unable to figure out why the session file is not getting created. Any pointers on my mistake will be helpful
> 
> My test.tt <http://test.tt> is as follows
> 
> |<%USE Dumper%><h1>Dumpingthe settings variable </h1> <%Dumper.dump_html(settings)%> <h1> Dumping the session variable </h1><%Dumper.dump_html(session)%>|
> 
> The live url for this route is
> 
> Live URL
> <http://edaindia.com/test/var/bar>

Why do you expect it in the /tmp folder? This doesn't sound like a good choice for preserving sessions
across reboots.

At any rate, you can set session_dir configuration variable.

Regards
	Racke

> 
> Note: I am launching 2 separate domain using a common app.psgi file whose content is as follows
> 
> use Plack::Builder;
> use Dancer2 ':syntax';
> use lib '/home/starman/www/dyumnin/lib';
> use lib '/home/starman/www/edaindia/lib';
> 
> use dyumnin;
> use edaindia;
> 
> builder {
>     mount 'http://edaindia.com/'      => edaindia->to_app;
>     mount 'http://dyumnin.com/' => dyumnin->to_app;
> };
> 
> 
> -- 
> https://www.facebook.com/vijayvithal.jahagirdar
> https://twitter.com/jahagirdar_vs
> http://democracies-janitor.blogspot.in/
> 
> 
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
> 


-- 
Perl and Dancer Development




More information about the dancer-users mailing list