• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get logged_in session status in native php

#1
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.
Reply

#2
Hi,

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
Code:
//relative path to CI index.php
include('../../../index.php');
ob_end_clean();
$CI =& get_instance();
$CI->load->driver('session');

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

#3
@starchild,

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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.