Welcome Guest, Not a member yet? Register   Sign In
how to get logged_in session status in native php

(This post was last modified: 06-15-2020, 07:32 AM by starchild.)

We have a mix of CI-3 and plain PHP, and want to be able to identify if a user is logged in via CI, so that we can display certain content.

Is there a way to do this?

Thank you.

(This post was last modified: 06-15-2020, 08:01 AM by neuron.)


This is the code I used in some of my project:

update your CI index.php:

PHP Code:
//$system_path = 'system';
$system_path dirname(__FILE__) . DIRECTORY_SEPARATOR 'system';
//$application_folder = 'application';
$application_folder dirname(__FILE__) . DIRECTORY_SEPARATOR 'application'

In your non CI PHP code
//relative path to CI index.php
$CI =& get_instance();

//this this index I set with $this->session->set_userdata()
if(@$_SESSION['logged_in'] != TRUE){


There are many ways to track that information. I'll give you another example. I track when users log into my app. I put the date, time, userid and activity id(001 - Log In, 002 - Log Out, etc) into a audit table that tracks user app usage. I'm then able to pull which users are logged into the app and I have information for future statistical purposes as well.

Theme © iAndrew 2016 - Forum software by © MyBB