<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>selfoss support forum - Login timeout setting</title>
<link>https://forum.selfoss.aditu.de/</link>
<description>selfoss support forum</description>
<language>en</language>
<item>
<title>Login timeout setting (reply)</title>
<content:encoded><![CDATA[<blockquote><p>Is there a different way to keep the session alive, e.g. by cron job?</p>
</blockquote><p>Not really, at least not a simple one. You could copy the session cookie and then replicate a browser request using e.g. curl but that likely will not work on shared hosting so you would need an extra script. And then update the session cookie each time it expired.</p>
<p>I think your best option would indeed be setting <a href="https://www.php.net/manual/en/session.configuration.php#ini.session.save-path"><code>session.save_path</code></a> as you mention (sorry, I missed your last post). Something like the following patch should work after creating the <code>data/cache/sessions</code> directory (though I have not tested it thoroughly):</p>
<pre><code>--- a/src/common.php
+++ b/src/common.php
@@ -11,6 +11,15 @@ use Monolog\Logger;
 
 require __DIR__ . '/constants.php';
 
+ini_set('session.gc_maxlifetime', 30 * 24 * 60 * 60); // 30 days
+// Use a custom session directory so that sessions are not garbage collected by other services.
+ini_set('session.save_path', __DIR__ . '/../data/cache/sessions');
+// Restore the default probability to make GC run in 1/100 requests.
+// This is in case a web host disables GC in favour of a cron script,
+// which would not know about our custom save path.
+ini_set('session.gc_probability', 1);
+ini_set('session.gc_divisor', 100);
+
 /**
  * @param string $message
  *
</code></pre><p>Of the few downsides, I can see:</p>
<ul>
<li>The session directory being under www root is not a best practice from security stand point since it will be potentially easier to access. If a malicious user gets access to the directory listing, they will see files like <code>sess_15480c88b5d9c9bd5192f939ed05b885</code>, whose names contain a session cookie that can be used to steal active user session. The <code>.htaccess</code> shipped with selfoss will prevent accessing the directory but if you use other web server than Apache, you need to make sure it is properly configured. Nor does selfoss contain any code that allow listing the directory contents. But if you are running other scripts in the same context, you need to trust them that they do not allow bypassing this.<br />
</li><li>The directory will contain an empty file for every time an agent connects to selfoss (even a bot). I would not care about this.<br />
</li><li>Garbage collection might slow down 1% of requests. Probably not a concern either.<br />
</li><li>You will need to apply this change every time you update selfoss.</li></ul>]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=1484</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=1484</guid>
<pubDate>Tue, 22 Nov 2022 16:11:48 +0000</pubDate>
<dc:creator>jtojnar</dc:creator>
</item>
<item>
<title>Login timeout setting (reply)</title>
<content:encoded><![CDATA[<p>Well, I started seeing regular session termination on the server side recently since I have other php scripts running on the server. Sadly, I have no direct access to php.ini due to managed hosting, which only allows me to change certain variables in php.ini.</p>
<p>Is there a different way to keep the session alive, e.g. by cron job?</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=1483</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=1483</guid>
<pubDate>Mon, 21 Nov 2022 20:21:29 +0000</pubDate>
<dc:creator>micha83x</dc:creator>
</item>
<item>
<title>Login timeout setting (reply)</title>
<content:encoded><![CDATA[<p>Ok, thanks for the heads up.<br />
I had a read on the php documentation and now I am quite overwhelmed and scared to break things on my server ;D<br />
For example, I am tempted to enable <code>session.save_path</code>. However, I have no idea about the side effects of disabled garbage collection and having to deal with it via a cron job.<br />
Since my session was never ended after only 24 minutes in the past, I will first try how it works without without modifications to php.ini.<br />
In case, I run into trouble, I will report back.</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=1481</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=1481</guid>
<pubDate>Tue, 04 Oct 2022 19:23:23 +0000</pubDate>
<dc:creator>micha83x</dc:creator>
</item>
<item>
<title>Login timeout setting (reply)</title>
<content:encoded><![CDATA[<p>Right, the default cookie expiration is one month, but it is not the only factor you need to consider. There is also the <a href="https://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime"><code>session.gc_maxlifetime</code></a> option in <code>php.ini</code> that defaults to 24 minutes. And, what is worse, even if we changed it in selfoss, the session might still end up being cleaned by PHP when another app runs on the same server and has shorter lifetime. So I would recommend setting it in <code>php.ini</code> yourself.</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=1480</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=1480</guid>
<pubDate>Tue, 04 Oct 2022 14:40:33 +0000</pubDate>
<dc:creator>jtojnar</dc:creator>
</item>
<item>
<title>Login timeout setting (reply)</title>
<content:encoded><![CDATA[<p>This thread is old, but I did not find the question answered elsewhere. Thus, here is my workaround:</p>
<ul>
<li>In file helpers/Authentication.php look for <code>$cookie_expire =</code>.<br />
</li><li>Change the value following the equal sign to a larger value than a month,<br />
</li><li>This leads to a later expiration date for the login cookie in your browser.</li></ul><p>I am not proficient in php in any way, but looking at how the config.ini is accessed, you could also add the variable yourself:</p>
<ul>
<li> In file helpers/Authentication.php set <code>$cookie_expire = \F3::get('cookie_expire_seconds');</code>.<br />
</li><li> In file config.ini add a line <code>cookie_expire_seconds = 31536000</code>.<br />
</li><li> Do not delete the new line at end of the config.ini!<br />
</li><li> This results in a expiration time of one year.</li></ul>]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=1479</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=1479</guid>
<pubDate>Mon, 03 Oct 2022 18:37:39 +0000</pubDate>
<dc:creator>micha83x</dc:creator>
</item>
<item>
<title>Login timeout setting (reply)</title>
<content:encoded><![CDATA[<p>I also miss some setting there. Currently, I have to login almost each time when I want to see news. Would be great to extend it to at least one day.</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=405</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=405</guid>
<pubDate>Fri, 03 May 2013 08:50:11 +0000</pubDate>
<dc:creator>mkyral</dc:creator>
</item>
<item>
<title>Login timeout setting</title>
<content:encoded><![CDATA[<p>What is the default time that a user will remain logged in?</p>
<p>I have had to disable the public side so I know whether I am still logged in or I get errors opening an item and it being attempted to be marked read.</p>
<p>Can this be changed?</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=395</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=395</guid>
<pubDate>Sun, 28 Apr 2013 22:27:57 +0000</pubDate>
<dc:creator>geniusmusing</dc:creator>
</item>
</channel>
</rss>
