# Panel keeps logging me out

**URL:** <https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747>\
**Category:** Questions\
**Tags:** v2\
**Created:** [December 6, 2015, 10:30pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747 "2015-12-06T22:30:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnViking](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tnviking/32/4407_2.png) [@tnViking](https://forum.getkirby.com/u/tnViking)\
**Post date:** [December 6, 2015, 10:30pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/1 "2015-12-06T22:30:56Z")

</div>

I’ve updated to latest panel, kirby and toolkit version. (2.2.2)  
But Panel seems to log me out at most unreasonable times, I save a page, try to edit again, and I’m returned to the login page of the panel.  
Or I try to navigate within the panel, when I’m suddenly directed to the login page again.

---

<div class="post-metadata">

**Author:** ![jevets](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jevets/32/978_2.png) [@jevets](https://forum.getkirby.com/u/jevets)\
**Post date:** [December 7, 2015, 2:42pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/2 "2015-12-07T14:42:17Z")

</div>

Are you using `csrf()` anywhere on the front end?

I’ve built custom forms and use the `csrf()` function for tokens, but if I have a panel edit page open, then view my custom form, the session’s token is replaced with my custom form’s token, therefore invalidating the panel’s edit form, which results in kicking me out of the panel.

---

<div class="post-metadata">

**Author:** ![tnViking](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tnviking/32/4407_2.png) [@tnViking](https://forum.getkirby.com/u/tnViking)\
**Post date:** [December 7, 2015, 7:51pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/3 "2015-12-07T19:51:41Z")

</div>

Nope, not using `csrf()` anywhere

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [December 7, 2015, 8:01pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/4 "2015-12-07T20:01:47Z")

</div>

This is really weird. Could you please send me a message with some more details? I might need to have a closer look at your installation: [bastian@getkirby.com](mailto:bastian@getkirby.com)

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [January 27, 2016, 7:25pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/5 "2016-01-27T19:25:21Z")

</div>

Hi @bastianallgeier and @tnViking … I’m getting this problem a lot.

Sometimes it stays logged for a minute, sometimes the login doesn’t even happens… pretty random thou.

I did some testing in several different connections, in the coworking place I use to hangout the local network have several internet providers and a load balance hardware to join them in one single access point. It’s almost impossible to use the panel there.

At home on ADSL or using my mobile phone’s 4g the panel stays logged normally.

Is there any check or something to turn off that makes it work?

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [January 27, 2016, 7:29pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/6 "2016-01-27T19:29:46Z")

</div>

BTW… I’m using Dreamhost… any previous experience or issues in this regards with them?

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [January 27, 2016, 7:40pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/7 "2016-01-27T19:40:11Z")

</div>

Dev tools console spits out the following when I’m logged in:

```auto
Refused to execute script from 'http://localhost/panel/plugins/js?v=2.2.3' 
because its MIME type ('text/html') is not executable, 
and strict MIME type checking is enabled. 

```

😒

[edit] Also sometimes the console shows:

```auto
Uncaught SyntaxError: Unexpected token <

```

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [January 28, 2016, 10:17am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/8 "2016-01-28T10:17:47Z")

</div>

Could you please send me an email. It would be perfect if I could run some tests on my own: [bastian@getkirby.com](mailto:bastian@getkirby.com)

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [January 28, 2016, 2:15pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/9 "2016-01-28T14:15:23Z")

</div>

Email sent! 👍

---

<div class="post-metadata">

**Author:** ![piper](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/piper/32/1869_2.png) [@piper](https://forum.getkirby.com/u/piper)\
**Post date:** [March 25, 2016, 8:40am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/10 "2016-03-25T08:40:00Z")

</div>

Hm, I’m having some very odd problems with this on a site as well! It didn’t happen at all when I was developing locally, but my client has been experiencing frequent log outs both on the staging site and on the live site (TSOhost). I haven’t done enough digging yet to see if I’m experiencing the same errors as @rhawbert, I’ll take a look at that next.

Any tips about what might be going on in the meantime?

---

<div class="post-metadata">

**Author:** ![rhawbert](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rhawbert/32/586_2.png) [@rhawbert](https://forum.getkirby.com/u/rhawbert)\
**Post date:** [March 28, 2016, 4:49pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/11 "2016-03-28T16:49:51Z")

</div>

After getting some help form @bastianallgeier whom instructed me to turn off some off the CSRF from the core altogether… I ended up partially disabling it in the file: `kirby/toolkit/lib/s.php`.

I edited the line `113` from:

```php
return sha1($_SERVER['HTTP_USER_AGENT'] . (ip2long($_SERVER['REMOTE_ADDR']) & ip2long('255.255.0.0')));      

```

to:

```php
return sha1($_SERVER['HTTP_USER_AGENT']);      

```

If I disabled the whole thing, replacing lines 111 to 117 by this:

```php

public static function fingerprint() { 
  return ''; 
}

```

Then I’d get a kind of “cross-login”, when two different users are logged from different locations/ip’s and one of the users get the wrong session and appear to logged as the other one.

I’m using the former solution so far without problems (using dreamhost).

---

<div class="post-metadata">

**Author:** ![tnViking](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tnviking/32/4407_2.png) [@tnViking](https://forum.getkirby.com/u/tnViking)\
**Post date:** [March 28, 2016, 5:05pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/12 "2016-03-28T17:05:33Z")

</div>

I did a fix on that in the toolkt pull [#146](https://github.com/getkirby/toolkit/pull/146). Could you try that, and see if it works?  
I haven’t had this issue for a while, so I’m not sure how to check it.  
It’s been commited to the dev branch of toolkit, so I guess It’ll be in a future release

---

<div class="post-metadata">

**Author:** ![fredr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/fredr/32/1909_2.png) [@fredr](https://forum.getkirby.com/u/fredr)\
**Post date:** [April 5, 2016, 3:46pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/13 "2016-04-05T15:46:32Z")

</div>

You might want to check that `$_SERVER['REMOTE_ADDR']` is set to the actual client IP in your hosting setup,

I got the same problem when hosting this in GCP k8s, because REMOTE\_ADDR will be an ip to a proxy, and not the client ip, and it changes between requests. So I get logged out when that happens.

---

<div class="post-metadata">

**Author:** ![ik\_arno](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@ik\_arno](https://forum.getkirby.com/u/ik_arno)\
**Post date:** [April 25, 2016, 9:56am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/14 "2016-04-25T09:56:09Z")

</div>

I’m having the same issues and I can’t figure out whats going on.

For my current projects panel (latest Kirby):  
On my localhost I never get logged out.  
On the development server I never get logged out.

On the same development server the client, at some days, gets logged out constantly and at some days not.  
(she tried various browsers and two different computers, reboots and everything)

It happens with or without the return sha1($\_SERVER[‘HTTP\_USER\_AGENT’]); change.

(On other projects, I basically never get logged out and my collegae does sometimes when we work together on the same site)

Very frustrating because I just can’t understand why 🙂

Anyone have another idea?

Thanks,  
Arno

---

<div class="post-metadata">

**Author:** ![anon77445132](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon77445132](https://forum.getkirby.com/u/anon77445132)\
**Post date:** [April 25, 2016, 10:01am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/15 "2016-04-25T10:01:07Z")

</div>

What’s about the cookies in the browsers of the users?  
Are they allowed?  
Or deleted by an Add-On?

Kirby gives users normaly a session cookie!

---

<div class="post-metadata">

**Author:** ![tnViking](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tnviking/32/4407_2.png) [@tnViking](https://forum.getkirby.com/u/tnViking)\
**Post date:** [September 28, 2016, 10:12pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/16 "2016-09-28T22:12:47Z")

</div>

Started to get this issue again, when I started using nginx and php-fpm on my mac.  
Each time I edit a file, I am logged out of the panel. Any clues why?

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [September 29, 2016, 6:40am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/17 "2016-09-29T06:40:45Z")

</div>

When that happends to me, it’s always that I get a new IP. Really frustrating when trying to save all the work and just got logged out.

I think it’s a major problem and I hope to see persistent cookies to prevent this behavior every time the IP is changed.

---

<div class="post-metadata">

**Author:** ![tnViking](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tnviking/32/4407_2.png) [@tnViking](https://forum.getkirby.com/u/tnViking)\
**Post date:** [September 29, 2016, 6:42am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/18 "2016-09-29T06:42:47Z")

</div>

I don’t get a new IP, I’ve got a static IP from my ISP and static internal IP. So nothing here should change my IP.

---

<div class="post-metadata">

**Author:** ![tnViking](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tnviking/32/4407_2.png) [@tnViking](https://forum.getkirby.com/u/tnViking)\
**Post date:** [September 29, 2016, 9:08am UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/19 "2016-09-29T09:08:10Z")

</div>

I see it happens when I use browsersync.  
I proxy [domain.com](http://domain.com) on port 3000, and it reloads on each save file.  
But I am logged in on [domain.com/panel](http://domain.com/panel)

But if I’m logged in on [domain.com:3000/panel](http://domain.com:3000/panel), it does not log me out.  
So it might be something that the browsersync proxy messes up the session/ cookies.

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [November 18, 2016, 1:58pm UTC](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747/20 "2016-11-18T13:58:39Z")

</div>

I just published a change on the develop branch of the toolkit, which will make it possible to create your own session fingerprint.

```auto
<?php

s::$fingerprint = function() {
  return 'some fingerprint';
};

```

In scenarios, where IP or user agent based session fingerprints won’t work, you can avoid problems that way.

[Next page](https://forum.getkirby.com/t/panel-keeps-logging-me-out/2747.md?page=2)
