Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7458767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:29:42+00:00 2026-05-29T13:29:42+00:00

I am trying to figure out how sessions work in Codeigniter. Reading the online

  • 0

I am trying to figure out how sessions work in Codeigniter. Reading the online manual, I see the following:

If sessions data does not exist (or if it has expired) a new session will be created and saved in the cookie. If a session does exist, its information will be updated and the cookie will be updated. With each update, the session_id will be regenerated.

and

Note: Session cookies are only updated every five minutes by default to reduce processor load. If you repeatedly reload a page you’ll notice that the “last activity” time only updates if five minutes or more has passed since the last time the cookie was written. This time is configurable by changing the $config[‘sess_time_to_update’] line in your system/config/config.php file.

Question:

  1. What information is updated if a session exists when a page with session class is loaded? Is this the session id stored in the cookie, or the session data itself stored in the database?
  2. Session cookies are only updated every 5 minutes. What if the user goes from page A to page B within 5 minutes, and this requires the addition of new session data? Logically the session data should be updated, so I guess I’m understanding this line wrongly… In this case, I will guess that the session cookie gets a new session id every 5 minutes.

Any clarifications will help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:29:43+00:00Added an answer on May 29, 2026 at 1:29 pm

    Yes, is about the session id stored in the cookie. This is regenerated every 5 minutes. And when it’s time to regenerate, first it will get current session data and than assign it to the new session id.

    code from CI session library, function sess_update():

    // Save the old session id so we know which record to
    // update in the database if we need it
    $old_sessid = $this->userdata['session_id'];
    $new_sessid = '';
    while (strlen($new_sessid) < 32)
    {
        $new_sessid .= mt_rand(0, mt_getrandmax());
    }
    
    // To make the session ID even more secure we'll combine it with the user's IP
    $new_sessid .= $this->CI->input->ip_address();
    
    // Turn it into a hash
    $new_sessid = md5(uniqid($new_sessid, TRUE));
    
    // Update the session data in the session data array
    $this->userdata['session_id'] = $new_sessid;
    $this->userdata['last_activity'] = $this->now;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out this pseudo code. The following is assumed.... I can only
I'm trying to figure out if it is better to store my user's data
I'm trying to figure out why this doesn't work. Let's say you three models,
I'm trying to figure out how to best use Sessions in (N)Hibernate. I have
I'm having difficulty trying to figure this out. I'm not even sure if it's
Trying to figure out an equation to get the current group a page would
Trying to figure out the best way to set up collection lists for users
Trying to figure out which to use.
Trying to figure out how to programmatically access the web pages in the application.
Trying to figure out the best way to do this: Should I do something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.