Well if this is on Laravel you can send _token
which call as csrf_field
by them.
In CI you can do like this. (csrf
generate unique session id)
Path - application/config/config.php
$config['csrf_protection'] = TRUE;
In Login form, you can add this or in page initialize you can add this
$csrf = array(
'name' => $this->security->get_csrf_token_name(),
'hash' => $this->security->get_csrf_hash()
);
<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />
So when saving you can add this to the session. BTW this token can use for cookie as well.
Read this Cross-site request forgery (CSRF)
Tokens may be either regenerated on every submission (default) or kept the same throughout the life of the CSRF cookie. The default regeneration of tokens provides stricter security, but may result in usability concerns as other tokens become invalid (back/forward navigation, multiple tabs/windows, asynchronous actions, etc). You may alter this behavior by editing the following config parameter
Source Codeigniter documentation
If it's not in a login page, then
Its better to se this false
,(due to this Tokens may be either regenerated on every submission (default))
$config['csrf_regenerate'] = FALSE;