Jump to content

Is it possible to share session with subdomain


apeisa
 Share

Recommended Posts

I am doing first multilang site, using languageFields. I decided to use subdomain for Spanish site and site defaults to English (pretty special site for us, no Finnish at all and true multilang).

It all works nice, but when admin clicks es.domain.com link PW loses the session and he/she needs to login again. Is there any way to have *.domain.com session?

Link to comment
Share on other sites

Ah, I somehow assumed that login in to subdomain expires the normal login. This is not the case. So after two logins no other logins needed. So no really need for this (and *.domain.com cookies are bad if you are using assets.domain.com for your static assets delivery).

Link to comment
Share on other sites

Maybe there's a better way I'm not thinking of, but one possibility might be to duplicate the login post to the other domain, from the client side with a little jQuery:

if($input->post->submit_login) {
   $username = wire('sanitizer')->username($input->post->username); 
   $pass = $input->post->pass; 
   $user = wire('session')->login($username, $pass); 
   if($user) {
       echo "<h2>Login successful!</h2>";
       echo "<script type='text/javascript'>";
       echo "$(document.ready(function() {";
       echo "$.post('http://es.domain.com/{$page->url}', { username: '$username', pass: '$pass' });";
       echo "});</script>";
   } else {
       echo "<p>Login failed  </p>";
   }
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...