@Snapey @maisnamraju I'm not saying there's nothing wrong with your setup (config), but yes session token WILL change on every request, but the token in a post should also change for the match (test when posted token = session token). Just seems a lot of people are having trouble.
I confess, most of the "built-in" stuff I don't use or like. I write my own Auth and my own csrf routines based on Chris Shiflet articles. They are sound and good.
Quick example from a custom framework controller:
$token = Cln::setToken();
Session::set('token', $token);
// other code
View::layoutMake($path, null, $layout, $title, $token, $dog);
In view:
//code
<input type="hidden" name="token" value="<?php echo $token; ?>" />
//code
Back in controller after form is posted:
if (isset($_POST['submit'])) {
$mytkn = Session::get('token');
$hastoken = Cln::fixTok($mytkn);
if ($hastoken == "notvalid") {
Session::set('token', md5(uniqid(rand(), TRUE)));
// to spoil a spoof. To make sure no match if a problem.
}
if ($_POST['token'] != Session::get('token')) {
Url::redirect('admin'); // or to where ever.
}
// all good continue on
The fixTok function
public static function fixTok($tosess = null)
{
$tosess = (is_null($tosess) || empty($tosess) || strlen($tosess) < 1 ? 'notvalid' : trim($tosess));
return $tosess;
}
Tested with fake and no tokens passed, all works good.