Posts Tagged session

Using Session in CI

Using  Session:

For using Session in CI must have to add this following line:

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

Important Note: If you have to use session for different pages, in that case u have to write this same line each and every time. So, better not to use this line, but play with the CONFIG folder.

  • go to the location “http://localhost/PROJECT_FOLDER/system/application/config/
  • open the file “autoload.php”
  • than rewrite the variable $autoload['libraries'] =  array( ‘session‘);

After than should have to assign session value like array:

[array]

( ’session_id’    => random hash,

‘ip_address’    => ’string – user IP address’,

‘user_agent’    => ’string – user agent data’,

‘last_activity’ => timestamp )

Retrieving  data from session:

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

Adding Custom Session Data:

$this->session->set_userdata( $array );

Where $array is an associative array containing your new data. Here’s an example:

$sessionArry= array(

‘username’  => ‘Lizee’,

‘email’     => ‘lizee@mysite.com’,

‘logged_in’ => TRUE,

‘usertype’ => ’superAdmin’,

);

$this->session->set_userdata( $sessionArry );

userdata , set_userdata are the library function. So, never and every change those.


Add comment August 21, 2009


My Profile


# Software Eng. # Worked with C,C++, JAVA and PHP. #Love to play with codes. # Mostly like to do programming with 'C'. # I am not a CODER, but a DEVELOPER.

Admin Panel..

Life Cycle

December 2009
S S M T W T F
« Sep    
 1234
567891011
12131415161718
19202122232425
262728293031  

Clouds

cakephp codeIgniter desktop htaccess jscript linux mixed my words php regular expression

Just Posted

TOP R@TED

TaGs

cakephp codeIgniter desktop GP htaccess image upload installation jscript linux news password Personal Life php regular_Xpression script session validation

Archives

Top Posts

CoMmEnTs

Blog Stats

My Web Links

Web Links

RSS Xperts.PHP