parent
bc261ebc2a
commit
0e74571a15
@ -0,0 +1,19 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/** |
||||
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||
* @copyright (c) 2025, Robert Strutts |
||||
* @license MIT |
||||
*/ |
||||
|
||||
use CodeHydrater\bootstrap\configure as Config; |
||||
|
||||
Config::set('redis', [ |
||||
// 'host' => 'redis.example.com', |
||||
'port' => 6379, |
||||
'auth' => 'your_redis_password', |
||||
'prefix' => 'PROJECT_SESSIONS:', |
||||
]); |
||||
|
||||
@ -0,0 +1,9 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
use CodeHydrater\bootstrap\configure as Config; |
||||
|
||||
Config::set('security', array( |
||||
'show_dumps' => true, |
||||
)); |
||||
@ -0,0 +1,19 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/** |
||||
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||
* @copyright (c) 2025, Robert Strutts |
||||
* @license MIT |
||||
*/ |
||||
|
||||
use CodeHydrater\bootstrap\configure as Config; |
||||
|
||||
Config::set('sessions', [ |
||||
'type' => 'cookies', // Session Type: php, files, redis, or cookies |
||||
'session_variable' => 'ses_app_', // set session variable name for project |
||||
'session_name' => 'main_SESS', // More secure then PHPSESSID |
||||
'session_table' => false, // DB PHP Session Table name, false = USE FILES |
||||
'session_key' => '73bf4a217c532ee59d22f7279e677750', |
||||
]); |
||||
@ -0,0 +1,34 @@ |
||||
<?php |
||||
|
||||
declare(strict_types = 1); |
||||
|
||||
/** |
||||
* @author Robert Strutts <Robert@TryingToScale.com> |
||||
* @copyright Copyright (c) 2022, Robert Strutts. |
||||
* @license MIT |
||||
*/ |
||||
namespace Project\controllers\app; |
||||
|
||||
/** |
||||
* Description of cookie_ctrl |
||||
* |
||||
* @author Robert Strutts <Robert@TryingToScale.com> |
||||
*/ |
||||
class cookie_ctrl { |
||||
|
||||
public function __construct() { |
||||
\CodeHydrater\session_management::start(); |
||||
} |
||||
|
||||
public function save() { |
||||
$_SESSION['admin'] = "Bob"; |
||||
$_SESSION['logged_in'] = true; |
||||
echo "Saved..."; |
||||
} |
||||
|
||||
public function read() { |
||||
var_dump($_SESSION); |
||||
// var_dump($_SESSION['admin'] ?? ""); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/** |
||||
* @author Robert Strutts <Bob_586@Yahoo.com> |
||||
* @copyright (c) 2025, Robert Strutts |
||||
* @license MIT |
||||
*/ |
||||
|
||||
// A more secure class is: \CodeHydrater\services\sodium_storage |
||||
|
||||
use CodeHydrater\bootstrap\registry as Reg; |
||||
|
||||
Reg::get('di')->register('session_encryption', function($args) { |
||||
try { |
||||
if (! \CodeHydrater\bootstrap\configure::has('sessions', 'session_key')) { |
||||
|
||||
$testing = new \CodeHydrater\services\encryption(); |
||||
echo "Here is a Key to use: " . $testing->generate_valid_key(); |
||||
die("Please assign the config for sessions, session_key!"); |
||||
} |
||||
|
||||
$enc = new \CodeHydrater\services\encryption( |
||||
\CodeHydrater\bootstrap\configure::get('sessions', 'session_key') |
||||
); |
||||
$enc->change_security_level("lighting"); // Quickest but not secure... |
||||
return $enc; |
||||
} catch (\Exception $e) { |
||||
|
||||
} |
||||
}); |
||||
Loading…
Reference in new issue