Esempio n. 1
0
 /**
  * Generate a new serial format for session IDs.
  *
  * @return string The serial
  */
 public function generateSessionSerial()
 {
     $filename = APP_ROOT . 'config/session.yaml';
     // Get the contents of the config file
     $yaml = file_get_contents($filename);
     // Create a pattern for the session ID
     $serial = Serial::createPattern(64);
     // Replace the id_format value in the config file with the new pattern
     $regex = '/^\\s*id_format:\\s*.*/m';
     $replace = "id_format: {$serial}";
     $yaml = preg_replace($regex, $replace, $yaml);
     // Store the new YAML content in the config file
     file_put_contents($filename, $yaml);
 }
Esempio n. 2
0
 /**
  * Generate a new session ID.
  *
  * @return bool
  */
 private function generateId()
 {
     return session_id(Serial::generate($this->config->id_format ?: self::DEFAULT_ID_FORMAT));
 }