dear M users. I am planning to run a hypnotoad server that controls the entire domain ( syllabus.space ). Thus, I want auth.syllabus.space and info.syllabus.space to share the session. is this possible? advice appreciated. regards, /iaw
app->secret( [ 'you', 'me', 'us' ] );app->sessions->cookie_domain( getfinaltwo( $self->req->url->to_abs->host ) );app->start();
get '/' => sub {my $c = shift;$c->app->sessions->cookie_domain(getfinaltwo($c->req->url->to_abs->host));$c->session(a=>1)->render(text=>"\n");};app->start;sub getfinaltwo { shift =~ s!^.*?((\.[^\.]+){2})$!$1!r }
--
You received this message because you are subscribed to a topic in the Google Groups "Mojolicious" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mojolicious/r6XS1Tc2OM8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mojolicious+unsubscribe@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.
thanks, stefan. This will do if need be, but I was hoping there was a way to tell the app the cookie method right from start, rather than sticking this into each and every url.
my $c = shift;$c->app->sessions->cookie_domain(getfinaltwo($c->req->url->to_abs->host));
};get '/1' => sub {my $c = shift;
$c->session(a=>1)->render(text=>"\n");};
get '/2' => sub {my $c = shift;$c->session(b=>2)->render(text=>"\n");
#!/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;
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.