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

  • Home
  • SEARCH
  • 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 1047823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:21:40+00:00 2026-05-16T16:21:40+00:00

I have recently started using CI and with it CI sessions, but I have

  • 0

I have recently started using CI and with it CI sessions, but I have noticed that one thing in particular is much more time consuming to do with CI sessions than with the base PHP sessions: Arrays.

I have an array of data that persists regardless of login/logout called $_SESSION['stats'], I then store data in that array in the form:

$_SESSION['stats']['last_page'] = $_SERVER['REQUEST_URI'];.

And when a user logs out, it saves the stats array in a variable, clears the session, and then loads it back into the new session.

The problem is that in order to edit the last_page key, instead of the one line above, I have to use this code:

$stats = $this->CI->session->userdata('stats');
$stats['last_page'] = $_SERVER["REQUEST_URI"];
$this->CI->session->set_userdata('stats', $stats);

This is one of a number of annoyances I find in CI sessions, which cause me to feel dissatisfied with it as my session handler. So my question is: Which session system should I use with CodeIgniter?… is there some reason for using CI sessions? Is there a CI library that you would suggest? Why not just use PHP sessions?

Thanks,

Lemiant

  • 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-16T16:21:41+00:00Added an answer on May 16, 2026 at 4:21 pm

    CI sessions offers some extra functionality; such as auto regenerating the session id every given amount of time (for security), IP address tracking, and flashdata (session data that’s cleared after it’s read once).

    CI’s session mechanism stores all the data in a cookie. PHP’s native session mechanism is stored server side. Each have it’s advantages/disadvantages. Cookies can only hold 4KB of data, so if your storing large amounts of data in session PHP native sessions might be better.

    If you decide to you want to use native PHP sessions use: Session Hybrid (CI 1.7.2)

    Session Hybrid uses native PHP sessions, can store session data in the default CI db, is a drop-in replacement for CI’s session class, and only requires one file to be rewritten.

    [* If using a CI version before 1.7.0 try PHPSession and Native Session]

    Side note: If you choose to stay with CI’s sessions, for additional security you can store sessions in a database and encrypt the cookies (see Session Preferences).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently started using WPF and the MVVM framework, one thing that I have
I have recently started using generics in java, and in that attempt tried to
I have recently started looking into using Azure but I'm having some issues getting
I've recently started using CMake for one of my multi-platform projects, but I'm having
I have recently started using Vim as my text editor and am currently working
I have recently started having problems with TortoiseCVS, or more specifically with plink, the
I have recently started working on a very large C++ project that, after completing
I have recently started learning F#, and this is the first time I've ever
I have recently started exploring Maven, but I feel a bit overwhelmed of all
I have recently started learning Perl and one of my latest assignments involves searching

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.