Integrating CodeIgniter with Wordpress
This is causing me no end of grief, I thought I had cracked it but it seems I still have a problem.
wordpress is at root level /
codeigniter is off the root in /ci/
I thought it was ok, I could call wordpress functions from codeigniter like get_header(); etc
The first issue I had was I was unable to access the 'routes' attribute from a standard CI controller:
'ci' was NULL.
To resolve this issue I did; $this->ci = get_instance();
Which seemed to fix it. Whether this is the correct way of doing so or not I don't know.
I then have a login function, which commits some data to a session object. I do this in a Custom CI library class like so:
$CI =& get_instance();
'logged_in' => true,
'user_id' => $row['user_id'],
'username' => $row['username'],
'user_type_id' => $row['user_type_fk'],
'user_role' => json_encode($usr_role),
'theme' => $row['theme_url']
I have done a var_dump after this line on $CI->session->userdata and they have been set. Once logged in I redirect the user to another page, which uses a 'secure controller' (basically checks the user is logged in to access the page. This inherits from CodeIgniters standard 'CI_Controller'
However, when I do $this->session->userdata on this page, there is a session there, but it has a different session_id and none of my previous userdata. Each time I refresh this page a new session id is created. This is not the functionality I expect at all. I expect this to have the same session id which is maintained throughout, including my previously set userdata.
What am I doing wrong, and any suggestions?