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 6128745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:39:42+00:00 2026-05-23T16:39:42+00:00

I want to destroy restore the session id and then start the session, which

  • 0

I want to destroy restore the session id and then start the session, which is done in standard PHP like following. How can I do this in CodeIgniter?

session_destroy();
session_id($old_session_id);
session_start();

I think session is started automatically by autoloading the library:

$autoload['libraries'] = array('session');

Is it so? How can I use the session_id($old_session_id); in CodeIgniter?
I’m trying with $this->session->set_userdata('session_id', $old_session_id);

But it seems that something is not working fine, as i can not get the session data. Any idea if anything is wrong with the above lines or something else?
Thanks.

  • 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-23T16:39:42+00:00Added an answer on May 23, 2026 at 4:39 pm

    Some things to check for:

    1. Check to ensure sessions are working in PHP without CodeIgniter. If sessions do not work then your server is not saving session info correctly

    2. Check if you are saving session information to the database or not (In application/config/config.php does $config[‘sess_use_database’] equal FALSE? If TRUE, then make sure to have this code imported into your DB

     

    CREATE TABLE IF NOT EXISTS  `ci_sessions` (
        session_id varchar(40) DEFAULT '0' NOT NULL,
        ip_address varchar(16) DEFAULT '0' NOT NULL,
        user_agent varchar(50) NOT NULL,
        last_activity int(10) unsigned DEFAULT 0 NOT NULL,
        user_data text DEFAULT '' NOT NULL,
        PRIMARY KEY (session_id)
    );
    

    If something is not correct here then CI is not saving session info.

    1. Try a bit more session testing using this snippet in a working controller function:

     

    $this->load->library('session'); // load session in controller
    echo $session_id = $this->session->userdata('session_id'); // print session id to page
    

    Check your error logs to see if CI is loading the session library module and no errors are present.

    This is more of a debugging strategy for sessions than a solution.

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

Sidebar

Related Questions

I want to create and then destroy buttons, all with code, but can't find
I want to destroy all i-frames of a video. Doing this I want to
want to have a Hyperlink-Button in a gridView in which I can display a
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
For debugging reasons I want to destroy a class instance which still as references.
My Devise/Warden-based app stores a model ID in the session[] variable. I want destroy
I want to explicitly destroy a vector in a templated context. The following works
I have some session data in a website. I want to destroy all session
I want to use the Assert keyword in my android apps to destroy my
We need to create & destroy instances of QApplication, as we want to use

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.