php - How to store variable in session codeignitor -


guys store variable in session tryin not working.

in controller

<?php session_start();  $_session['myvar']='myvalue'; ?> 

simple :

first, load library

$this->load->library('session'); 

then, add informations in session :

$newdata = array(                    'username'  => 'johndoe',                    'email'     => 'johndoe@some-site.com',                    'logged_in' => true                );  $this->session->set_userdata($newdata); 

next, if want values :

$session_id = $this->session->userdata('session_id'); 

and remove :

$this->session->unset_userdata('some_name'); 

a simple search "codeigniter session" have ...

http://ellislab.com/codeigniter/user-guide/libraries/sessions.html

don't forget upvote , mark solved if find useful :)


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -