Session "lost" after login

Recommended Posts

Dear community

I've had an annoying problem for a few days that's driving me nuts. In short: When a user successfully logs in to my website (frontend login form), the session get's lost almost immediately afterwards. What I mean is: The user variable is set to "guest" again. Funnily enough, this only happens when the language is set to German, but not when it's English...

Here's the longer story. First my setup:

  • PW 3.0.62
  • Multilanguage: German (default) and English
  • Multisite (using Soma's Multisite module)
  • ProCache and FormBuilder in use

The login is done in a separate browser (incognito Chrome), i.e., I'm not logged in parallel in the backend.

The symtoms are as follows:

  • Coming from a German page (i.e., URL starting with /de/...) and executing
    $user = session->login($username, $pw)
    wire('user')->language changes to English, which I don't understand. I assume it should remain German, shouldn't it? I read in a different post here that the user's profile language (backend setting) is ignored in such situations.
  • Immediately after successfully logging in, I redirect the request to the user's account page:

    After that, the session is lost. I.e., $user is set to "guest".

  • I notice a similar behaviour when submitting other (i.e., non-login) forms when "Session tracking and CSRF protection" is enabled: I get an "Invalid form submission" error in German, but all's fine in English. I noticed it had to do with the session ID, which is used to validate the submitted forms.

Can anyone explain these symptoms and/or give me a hint what could be wrong? I am happy to provide more details.

Many thanks!

  • Like 1

Share this post

Link to post
Share on other sites

Well, uh, FWIW I’ve encountered a problem today that may or may not be similar. My backend sessions were working as fine as ever, but users on the frontend would get logged out immediately after logging in. Basically, they would get their welcome page but their next request would fail.

After disabling Session Handler Database sessions would persist nicely.

Now when I saw you mention the Multilanguage setup, I had a look at my prepend file, where for some reason I can’t really remember I had put this:

$session->language = $user->language;

I’m sure once upon a time this fixed something about Language settings getting lost in between requests or something, but apparently it doesn’t play nice with the Session Handler Database module. So after removing that line everything is back to normal, DB sessions enabled and all.

I have no idea about the mechanics behind the effects I’m observing here, unfortunately, but I thought I’d throw it out there, I guess.

  • Like 1

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.