Skip to content

Commit 4cafacd

Browse files
authored
Sample encrypted cookie token
1 parent b1daa82 commit 4cafacd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sample-site/app.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
Basic::setJsonBodyAsPOST(); // JSON as $_POST
1919
Basic::setFirewall(); // Enable firewall
2020
// Basic::setHttps(); // Require TLS/HTTPS
21+
2122
Basic::setEncryption('SecretPassPhrase123'); // Encryption cipher method and pass phrase
23+
setcookie('token', Basic::encrypt('{"username":"user","role":"admin"}'), NULL, NULL, NULL, NULL, TRUE); // Sample token
24+
// var_dump(json_decode(Basic::decrypt($_COOKIE['token']), TRUE));
25+
2226
Basic::setAutoloadClass(['classes', 'models', 'views', 'controllers']); // Autoload folders
2327
Basic::setHomePage('HomeController@index'); // Homepage
2428
Basic::setAutoRoute(); // Automatic '/class/method' routing

sample-site/controllers/EncryptionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class EncryptionController
66
public function index()
77
{
88
$page_title = 'Data Encryption';
9-
$plaintext = 'ABC123';
9+
$plaintext = '{"username":"user","role":"admin"}';
1010
$encrypted = Basic::encrypt($plaintext);
1111
$decrypted = Basic::decrypt($encrypted);
1212

0 commit comments

Comments
 (0)