The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
CodeIgniter Integration / MVC Integration - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28) +--- Forum: Modifications and Hackery (https://userspice.com/forums/forumdisplay.php?fid=29) +--- Thread: CodeIgniter Integration / MVC Integration (/showthread.php?tid=781) |
CodeIgniter Integration / MVC Integration - userspicenewbie - 10-01-2017 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? CodeIgniter Integration / MVC Integration - Kighlander - 10-02-2017 I am also interested in a solution for CodeIgniter ... CodeIgniter Integration / MVC Integration - karsen - 10-02-2017 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? CodeIgniter Integration / MVC Integration - userspicenewbie - 10-02-2017 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. CodeIgniter Integration / MVC Integration - karsen - 10-02-2017 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 CodeIgniter Integration / MVC Integration - userspicenewbie - 10-02-2017 I think both UserSpice and CodeIgniter name the session as 'session'. That may be why CI overwrites the US session in the first place. CodeIgniter Integration / MVC Integration - userspicenewbie - 10-02-2017 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. CodeIgniter Integration / MVC Integration - karsen - 10-02-2017 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 CodeIgniter Integration / MVC Integration - userspicenewbie - 10-02-2017 CodeIgniter's sessions are executed first. CodeIgniter Integration / MVC Integration - karsen - 10-02-2017 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. |