Welcome Guest, Not a member yet? Register   Sign In
maybe need to modify session garbage collector section.
#1

(This post was last modified: 12-03-2018, 01:13 AM by eterv.)

I think that maybe need to modify session garbage collector section.

Session/Handlers/FileHandler.php
public function gc();

original code is ...

$pattern = sprintf(
  '/^%s[0-9a-f]{%d}$/', preg_quote($this->cookieName, '/'), ($this->matchIP === true ? 72 : 40)
);


but, why 40? I can't understand this.

for example, one of my session file name is a_sessionba2o0ekqqv8ogvqonrl2u0uqg86so8fm
a_session is cookiename.
so, session id is "ba2o0ekqqv8ogvqonrl2u0uqg86so8fm". the length of this string is 32.

So, actually, in my case 32 is correct value.
and I found this code part.

in Session/Session.php
protected function configureSidLength();

after be called this function, sidRegexp value is, "[0-9a-v]{32}" (in my case)

So, I tried to modify gc part code.

Here are some code.

PHP Code:
       $sid_regexp '';
 
       $bits_per_character = (int) (ini_get('session.sid_bits_per_character') !== false ini_get('session.sid_bits_per_character') : 4);
 
       $sid_length = (int) (ini_get('session.sid_length') !== false ini_get('session.sid_length') : 40);
 
       switch ($bits_per_character) {
 
           case 4$sid_regexp '[0-9a-f]'; break;
 
           case 5$sid_regexp '[0-9a-v]'; break;
 
           case 6$sid_regexp '[0-9a-zA-Z,-]'; break;
 
       }
 
       $sid_regexp .= '{' $sid_length '}';
 
       $pattern sprintf'/^%s%s$/'preg_quote($this->cookieName'/'), $sid_regexp );

 
       /* // Original Code
        $pattern = sprintf(
                '/^%s[0-9a-f]{%d}$/', preg_quote($this->cookieName, '/'), ($this->matchIP === true ? 72 : 40)
    );*/ 


After modify it, Finally My php Garbage Collector removed garbage session files.

So, please modify this part properly.
Reply


Messages In This Thread
maybe need to modify session garbage collector section. - by eterv - 11-26-2018, 11:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB