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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:26:50+00:00 2026-06-09T20:26:50+00:00

I am using Code Igniter and I am implementing a remember user functionality. Basically,

  • 0

I am using Code Igniter and I am implementing a remember user functionality.

Basically, from another stack overflow post, I implemented this the right way where I generate a random string for that user, save it in the database AND in a cookie. On site load, I check for that cookie, if that cookie is found I check it in the database. If it is found in the database then recrease the session for that user.

The problem I am having is when I load the site. I am getting the value of the cookie and I am also getting the correct response from the AJAX call. However, I have to click on a link in order for the session to get recreated (such as menu is displayed for logged in user and so on).

I am thinking that I am recreating the session AFTER the index method of the main controller is called. How can I get around this in Code Igniter? Where can I put this code which preferably gets run first thing on every page? As for instance I also want to recreate the session if the user enters the site’s contact us page instead of the home page.

Many thanks in advance.

  • 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-06-09T20:26:51+00:00Added an answer on June 9, 2026 at 8:26 pm

    CodeIgniter allows the developer to create hooks which are called at different moments before the controller method is called.

    Here is a short description of how to use hooks:

    http://codeigniter.com/user_guide/general/hooks.html

    If you want to access the session, I would recommend to use a post_controller_constructor hook, which is called after the controller constructor is executed, but before the action method is called. ( access the CI session in a pre controller codeigniter hook )

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

Sidebar

Related Questions

I am using Code Igniter, The HMVC library , and Smarty with this library
I have enabled google Minify in code igniter using this library on our website.
I am trying to design a user registration form using code igniter 2.1.0. I
I am using the standard code igniter profiling functionality to view performance breakdown for
I am using code igniter to retrieve data from a database What is returned
I am using code igniter to retrieve data from a database What is returned
enable compression / Enable Gzip I am using code igniter from three to four
My question is similar to this question but I'm not using code igniter. I'm
Im currently using Code Igniter to have pretty URLs, and I have this system
I am using the following code to select from a MySQL database with a

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.