# BUG SOLVED!: Maintaining Authentication after browser shutdown

**URL:** <https://www.patreondevelopers.com/t/bug-solved-maintaining-authentication-after-browser-shutdown/8893>\
**Category:** Wordpress Plugin\
**Created:** [May 28, 2024, 4:21am UTC](https://www.patreondevelopers.com/t/bug-solved-maintaining-authentication-after-browser-shutdown/8893 "2024-05-28T04:21:19Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![webhead](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/webhead/32/2698_2.png) [@webhead](https://www.patreondevelopers.com/u/webhead)\
**Post date:** [August 10, 2024, 6:53am UTC](https://www.patreondevelopers.com/t/bug-solved-maintaining-authentication-after-browser-shutdown/8893/7 "2024-08-10T06:53:21Z")

</div>

I actually found several other topics about this exact same thing and fortunately, a kind soul actually offered up some code to create a plugin to do this rather than manual editing (this is much better than having to edit the code every time there’s an update haha).

What I’d LOVE to see is for them to take this and just make it an option in the Patreon plugin itself because this is just going to happen sometimes. It doesn’t really matter if another plugin causes it or some server setting you have causes it because if you need those things to work that way anyway, you need this to be an option, right? I completely understand when the developer says “hey your environment is causing this” but the fact of the matter is, I can’t change it. I have what I have for whatever reasons and I can’t start disabling other plugins or changing my PHP settings. Also even if this worked as it is supposed to, the option to set the remember me setting is still preferable because it will ALWAYS last longer than the session method that was used in the plugin (and because if you have this issue it is fixed by that option).

I used that other guy’s code and then some more code to extend logins to 30 days (the time before a token refresh is required with Patreon). Should make things easier on my users!

> [@Patrons have to authorize every time](https://www.patreondevelopers.com/t/patrons-have-to-authorize-every-time/1650/7):
>
> I had this same issue. My solution was to add this plugin which simply re-sets the auth cookies after the Patreon plugin is done with auth’ing. This basically makes it act as if the user hit the “Remember Me” checkbox during login. \<?php /\*\* \* Plugin Name: Patreon - Stay Logged In Always (Patreon users only) \* Description: This makes it so that the user will always stay logged in, as if they hit "Remember Me". This is a workaround for the Patreon plugin. \* Version: 1.0.0 \* Author: Bennyc…

Sorry I know this is quite verbose, but to address the session cookies in general, they are supposed to delete on browser exit so this is not actually surprising behavior.

> **[Set-Cookie - HTTP | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)**
>
> The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent can send it back to the server later.
> To send multiple cookies, multiple Set-Cookie headers should be sent in the same response.

> [`Expires=<date>`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#expiresdate) Optional
> 
> Indicates the maximum lifetime of the cookie as an HTTP-date timestamp. See [`Date`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date) for the required formatting.
> 
> If unspecified, the cookie becomes a **session cookie**. A session finishes when the client shuts down, after which the session cookie is removed.
> 
> **Warning:** Many web browsers have a _session restore_ feature that will save all tabs and restore them the next time the browser is used. Session cookies will also be restored, as if the browser was never closed.
> 
> When an `Expires` date is set, the deadline is relative to the _client_ the cookie is being set on, not the server.

---

_[View the full topic](https://www.patreondevelopers.com/t/bug-solved-maintaining-authentication-after-browser-shutdown/8893)._
