@@ -389,59 +389,20 @@ protected function _configure(&$params)
389389 */
390390 protected function _configure_sid_length ()
391391 {
392- if (PHP_VERSION_ID < 70100 )
393- {
394- $ hash_function = ini_get ('session.hash_function ' );
395- if (ctype_digit ((string ) $ hash_function ))
396- {
397- if ($ hash_function !== '1 ' )
398- {
399- ini_set ('session.hash_function ' , 1 );
400- }
401-
402- $ bits = 160 ;
403- }
404- elseif ( ! in_array ($ hash_function , hash_algos (), TRUE ))
405- {
406- ini_set ('session.hash_function ' , 1 );
407- $ bits = 160 ;
408- }
409- elseif (($ bits = strlen (hash ($ hash_function , 'dummy ' , false )) * 4 ) < 160 )
410- {
411- ini_set ('session.hash_function ' , 1 );
412- $ bits = 160 ;
413- }
414-
415- $ bits_per_character = (int ) ini_get ('session.hash_bits_per_character ' );
416- $ sid_length = (int ) ceil ($ bits / $ bits_per_character );
417- }
418- else
419- {
420- $ bits_per_character = (int ) ini_get ('session.sid_bits_per_character ' );
421- $ sid_length = (int ) ini_get ('session.sid_length ' );
422- if (($ bits = $ sid_length * $ bits_per_character ) < 160 )
423- {
424- // Add as many more characters as necessary to reach at least 160 bits
425- $ sid_length += (int ) ceil ((160 % $ bits ) / $ bits_per_character );
426- ini_set ('session.sid_length ' , $ sid_length );
427- }
428- }
429-
430- // Yes, 4,5,6 are the only known possible values as of 2016-10-27
431- switch ($ bits_per_character )
432- {
433- case 4 :
434- $ this ->_sid_regexp = '[0-9a-f] ' ;
435- break ;
436- case 5 :
437- $ this ->_sid_regexp = '[0-9a-v] ' ;
438- break ;
439- case 6 :
440- $ this ->_sid_regexp = '[0-9a-zA-Z,-] ' ;
441- break ;
442- }
443-
444- $ this ->_sid_regexp .= '{ ' .$ sid_length .'} ' ;
392+ $ bits_per_character = (int ) ini_get ('session.sid_bits_per_character ' );
393+ $ sid_length = (int ) ini_get ('session.sid_length ' );
394+
395+ // We force the PHP defaults.
396+ if (PHP_VERSION_ID < 90000 ) {
397+ if ($ bits_per_character !== 4 ) {
398+ @ini_set ('session.sid_bits_per_character ' , '4 ' );
399+ }
400+ if ($ sid_length !== 32 ) {
401+ @ini_set ('session.sid_length ' , '32 ' );
402+ }
403+ }
404+
405+ $ this ->_sid_regexp = '[0-9a-f]{32} ' ;
445406 }
446407
447408 // ------------------------------------------------------------------------
0 commit comments