Last active
November 10, 2015 22:52
-
-
Save Rayne/b5bc2914ed3dd9243359 to your computer and use it in GitHub Desktop.
Fat-Free Framework: Session CSRF Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'base.php'; | |
$f3 = Base::instance(); | |
/** | |
* @see https://github.com/bcosca/fatfree/issues/878 | |
*/ | |
$f3->route('GET /session/@backend', function(Base $f3, array $args){ | |
$backend = $args['backend']; | |
if ($backend === 'cache') { | |
$f3->set('CACHE', true); | |
$session = new Session(); | |
} | |
else if ($backend === 'jig') { | |
$session = new DB\JIG\Session(new DB\Jig('database.jig/')); | |
} | |
else if ($backend === 'mongo') { | |
$db = new DB\Mongo('mongodb://localhost:27017', 'fatfree'); | |
$session = new DB\Mongo\Session($db); | |
} | |
else if ($backend === 'sql') { | |
$session = new DB\SQL\Session(new DB\SQL('sqlite:database.sqlite')); | |
} | |
else { | |
$f3->error(404); | |
} | |
echo "<h1>$backend</h1>"; | |
var_dump([ | |
'SESSION.csrf' => $f3->get('SESSION.csrf'), | |
'$session->csrf()' => $session->csrf(), | |
]); | |
$f3->set('SESSION.csrf', $session->csrf()); | |
}); | |
$f3->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for testing the Mongo backend.