Hello
As explained here , I set 2 variables in the panel to have a longer connection time in the panel:
c::set('panel.session.timeout', 3000);
c::set('panel.session.lifetime', 3000);
But still, the panel ask for credentials every 5 minutes or so…
What can I do to have a longer connection time in the panel?
Thank you
Kirby 2.5.6
You could try with a session fingerprint:
This is the fingerprint method:
public static function fingerprint() {
// custom fingerprint callback
if(is_callable(static::$fingerprint)) {
return call(static::$fingerprint);
}
if(!r::cli()) {
return sha1(Visitor::ua() . (ip2long($_SERVER['REMOTE_ADDR']) & ip2long('255.255.0.0')));
} else {
return '';
}
}
So, if no custom fingerprint is used, the fingerprint is created like this:
return sha1(Visitor::ua() . (ip2long($_SERVER['REMOTE_ADDR…
https://getkirby.com/changelog/kirby-2-4-1
https://getkirby.com/search?q=fingerprint - In the future maybe.
I use Kirby 2.4.1.
It says:
Allow custom session fingerprinting to avoid session invalidation in environments, where IP addresses or User Agents change often.
My enviroment changes IP:s often. That’s why I tried to add this to my config.php.
s::$fingerprint = function() {
return 'custom fingerprint';
}
It did not work. It says:
Parse error: syntax error, une…
Svnt
October 18, 2017, 8:49pm
3
Session life time can only be set in the php.ini [http://php.net/manual/de/session.configuration.php ]
If you can’t modify this setting, as everybody else on a cheap shared host, you can…
…get a ‘auto reload’ extension for your browser and open the dasboard in a new tab with the extension enabled.
… create a ‘custom field’ [https://getkirby.com/docs/developer-guide/panel/fields#adding-field-assets ]
with a js snipped that ajax polls the session alive.
(‘fingerprints’ (‘csrf tokens’ aswell) are there but just want work out of the box with kirby, at least for me)
–
svnt
Could you expand on that please? which code to use (and where)?
Ok. from here , I can add a custom fingerprint in config.php
, like so:
s::$fingerprint = function() {
return 'custom fingerprint';
};
Does it make sens to use the user_name
value in this custom fingerprint?
s::$fingerprint = function() {
return $user_name . '-fingerprint';
};
If so, how can I get the username inside config?
Thank you
You can get the current user with
$user = site()->user();
if($user) {
$username = $user->username();
}
Honestly, I don’t know if it makes sense to use the username or not. As far as I know, the fingerprint should be something unique. The original fingerprint is created like this:
public static function fingerprint() {
// custom fingerprint callback
if(is_callable(static::$fingerprint)) {
return call(static::$fingerprint);
}
if(!r::cli()) {
return sha1(Visitor::ua() . (ip2long($_SERVER['REMOTE_ADDR']) & ip2long('255.255.0.0')));
} else {
return '';
}
}
For testing if it makes any difference at all for your sessions , I’d use any simple string.
@texnixe Ok thanks, I try that.