CodeIgniter Laravel PHP Example Javascript jQuery MORE Videos New

Codeigniter CSRF Token Example


To add CSRF token security in your Codeigniter project please follow the below step.

Step 1:

Go to your config.php file

And Change the CSRF configuration like this.

<p>To add CSRF token security in your Codeigniter project please follow the below step.</p>
<p><strong>Step 1:</strong></p>
<p>Go to your config.php file</p>
<p>And Change the CSRF configuration like this.</p>

Step 2:

Then in your HTML form in view file

<input type="hidden" class="txt_csrfname" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>">

Add the below Input box

Example:

<form id="form-validation-simple" name="form-validation-simple" method="POST">
<input type="hidden" class="txt_csrfname" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>">
    <div class="row">
        <div class="col-md-6">
                <div class="form-group">
                <label class="form-label"> Topic Name  <span class="required">*</span> </label>
                <input
                    name="Name" id="Name" value="<?php echo $values->Name;?>" placeholder="Required, at least 4 characters" minlength="4" required
                    type="text"
                    class="form-control"
                    data-validation="[NOTEMPTY]"/>
                </div>
        </div>
    </div>