hi stefan---thanks for the help. it works without the hook, BUT there is a bug of some sort. I am not clear where.
firefox and safari cannot handle http://subdomain.localhost:3000/ ; only chrome can. this somewhat limits the testing to this one browser. run the following code in a chrome browser. there are essentially three modes now: 1. comment out the "$cookiedomain="localhost"" line, and run on localhost. cookies cannot cross subdomain, but they work within subdomains. this is M's normal behavior. 2. leave as is and run on localhost. chrome is now no longer able to change the cookie. it can still read the old cookie (set with 1). 3. comment out the "$cookiedomain="localhost" line, replace with the subsequent line (syllabus.space or whatever other domain you may have lying around), and run the code on this server domain. everything works perfectly now. the session can cross subdomains. I don't know whether this is an M bug or a chrome-localhost bug. this makes testing more difficult. the code can now run only in final production mode on the specific server, or I "hand-hook" it. #!/usr/bin/env perl use Mojolicious::Lite; my $cookiedomain; $cookiedomain= "localhost"; ## comment out to leave cookiedomain undef; then it works for each subdomain, but cookies cannot cross ## $cookiedomain= "syllabus.space"; ## this works just fine when on ; cookies can cross get '/' => sub { my $c= shift; ## not needed: ($cookiedomain) and $c->app->sessions->cookie_domain($cookiedomain); my $fulldomain= $c->req->url->to_abs->host; ($fulldomain =~ /$cookiedomain/) or die "please update the cookie domain to $fulldomain"; my $incookie= $c->session->{nicecookie} || "NO INCOOKIE DEFINED"; $c->session->{nicecookie}= time()." at ".$fulldomain; my $outcookie= $c->session->{nicecookie}; my $bigdomain= $cookiedomain || "localhost"; my $texts= qq( <h1> cookie tester </h1> <p>our incookie was '$incookie'</p> <p>our outcookie is '$outcookie'</p> <hr /> <p>you are currently in domain '$fulldomain' ($bigdomain)</p> <hr /> <p>main domain <a href='http://$bigdomain:3000/'>go to /</a></p> <p>subdomain <a href='http://s1.$bigdomain:3000/'>go to /s1</a></p> <p>subdomain <a href='http://s2.$bigdomain:3000/'>go to /s2</a></p> <hr /> <p>the cookiedomain is $cookiedomain.</p> ); $c->render(text => $texts); }; ($cookiedomain) and app->sessions->cookie_domain($cookiedomain); app->start; /iaw -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
