Remeber me Option in Codeigniter - Stack Of Codes

Breaking

Ads

Monday 29 January 2018

Remeber me Option in Codeigniter

Remeber me Option in Codeigniter::



#Set Cookie

if(isset($posted['rememberme']) && ($posted['rememberme'] == 'on' || $posted['rememberme']) ){

$cookie_prefix = 'stack_';
$user_cookie = array(
'name' => 'uname',
'value' => $posted['username'],
'expire' => '86400',
'domain' => '',
'path' => '/',
'prefix' => $cookie_prefix,
);
$this->input->set_cookie($user_cookie);

$pwd_cookie = array(
'name' => 'pwd',
'value' => $posted['password'],
'expire' => '86400',
'domain' => '',
'path' => '/',
'prefix' => $cookie_prefix,
);
$this->input->set_cookie($pwd_cookie);

}else {

delete_cookie("stack_uname");
delete_cookie("stack_pwd");
}

#For Get The Cookie data::

$getCookie_username = $this->input->cookie('stack_uname');
$getCookie_password = $this->input->cookie('stack_pwd');



#HTML FORM::

<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Username" name="username" value= "<?=$getCookie_username;?>" >
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="Password" name="password" value= "<?=getCookie_password;?>" >
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox" name="rememberme" value="1"  <?=($rememberme['is_remembered']) ? 'checked' : '' ?> > Remember Me
</label>
</div>
</div>
<div class="col-xs-4">
<button type="submit" name="signin" class="btn btn-primary btn-block btn-flat">Sign In</button>
</div>

</div>

No comments:

Post a Comment

Topics

PHP (27) CodeIgniter (22) SQL (4) Facebook (3) HTML (3) Blogger (2) Constructor (2) Destructor (2) Google (2) How to (2) Aadhaar (1) Agent (1) Browser (1) CSS (1) Cakephp (1) Constants (1) India (1) Ip address (1) JS (1) Jquery (1) Meta Tags (1) Robots (1) Scraping Data (1) escape_str (1) htaccess (1) iS mobile (1) javascript (1) mysqli (1)