The Session class allows you to keep track of a user's "state" and behaviour while they surf your website. There are a few session storage drivers included with CodeIgniter: database (default; file-system based) files

The data from sessions is accessible throughout the site, but we must first initialise the session before we can use it. We can accomplish that by using function Object() { [native code] } and performing the following code. $this->load->library('session'); You can utilise the session object as seen below after loading the session library.

To keep your session data, php creates an array. $new data = array('username' ='martin,' email' ='someone@martin.com,' user logged => TRUE); $this->session->set userdata($new data); Then call your session data as follows (create a variable and provide it the value of one of the session data you require):

echo "
"; print_r($this->session->all_userdata()); echo "
"; Display yet formatting then you can view properly. For print session data you do not need to use print_r() function every time . If you use it then it will be non-readable format.

A session is a server-stored global variable. A unique id is assigned to each session and is used to retrieve saved values. A cookie with the unique session id is kept on the user's computer and returned with every request to the server when a session is created.

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere