× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter Integration / MVC Integration
#1
Has anyone integrated UserSpice with CodeIgniter or any other model-view-controller (MVC) framework.

I installed UserSpice (US) in the root directory and everything in the demo pages works correctly.

Now within my CodeIgniter (CI) application, nothing seems to function. With this MVC framework, pages are created programmatically/dynamically within a single page controller within a different directory.

I adjusted all the paths and finally managed to get the header to appear. However, I noticed that even if I log into a UserSpice demo page on the same domain, I'm not really logged into any of the CodeIgniter based pages.

So I tried fooling around with the page 'users/classes/Users.php' to display a dump of the session variable: print_r($_SESSION);

On the demo page that functions properly, it displays:
Array ( [user] => 1 )

But on the CodeIgniter pages, it shows:
Array ( [__ci_last_regenerate] => 1506871995 )

It appears the CodeIgniter framework destroys the UserSpice sessions and overwrites it.

Any advice on rectifying?
  Reply
#2

I am also interested in a solution for CodeIgniter ...
  Reply
#3
UserSpice was designed as an alternative to MVC frameworks, and so I think it'll be very difficult to get the two to cooperate. You're essentially trying to use two frameworks at once. Can I ask what you want to use UserSpice for that Codeigniter isn't doing for you?
  Reply
#4
Unlike every other framework known to mankind, CodeIgniter has no built-in authentication protocols. For some reason, the developers refuse to add one despite constant demands.
  Reply
#5
I figured that would be too important and frequently-used to leave out. Let's see if we can help you out.

What I recommend instead is to use the UserSpice code to enhance your CodeIgniter site, modifying the login and permissions code as needed. To fix your session issue, it might be as simple as setting the UserSpice session name to the same as the CodeIgniter session name in
Code:
init.php
. I suggest starting there and seeing if that has any effect. I don't use CodeIgniter myself so I can't do any testing to help you out, but hopefully we can figure this out together.
  Reply
#6
I think both UserSpice and CodeIgniter name the session as 'session'. That may be why CI overwrites the US session in the first place.
  Reply
#7
I tried renaming the session in init.php and the same issue arises. I think CI destroys all sessions, no matter the name, before each page loads then reconstructs them.
  Reply
#8
In your code, which is executed first? The US session code or the CI session code? If US goes first, the answer might be to call
Code:
init.php
after and modify your US code to use the CI session name.
  Reply
#9
CodeIgniter's sessions are executed first.
  Reply
#10
Hmm, I tried looking at the CI docs and they didn't help me much. Maybe @mudmin can help us out when he sees this.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)