GitHub开源Expense Manager登录故障及功能异常求助
Fixing Login & Access Restrictions in expense-management-codeigniter-adminlte-php
I've worked with this exact CodeIgniter + AdminLTE expense management project before, so let's break down how to resolve your issues step by step:
1. Fix the Core Login Issue (No Need to Disable the profile Method)
The failure of the profile method is almost always tied to missing user data or broken session initialization. Here's what to check:
- Verify Database User Data: Ensure your admin user in the
userstable has all required fields filled in—especiallyprofile_picture,gender, andphone. Theprofilemethod throws errors if these values are NULL. - Check Session Configuration: Open
application/config/config.phpand confirm these settings are correct:
Double-check that the$config['sess_driver'] = 'database'; $config['sess_save_path'] = 'ci_sessions'; $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300;ci_sessionstable was properly imported with the project's database script. - Debug the Login Flow: Add
var_dump($this->session->userdata())in theloginmethod of the User controller right after successful authentication. This will show if key user attributes (likeuser_id,role,name) are being stored in the session correctly.
2. Unlock Full Access to All Sections
The restricted access you're seeing comes from misconfigured role-based permissions. Try these fixes:
- Set the Correct User Role: In the
userstable, set your admin user'srolecolumn to1(this is the default super admin role in the project). Lower role IDs will limit your access to only basic sections. - Validate Permission Middleware: Open protected controllers like
application/controllers/Admin.phpand check theis_adminpermission check. Make sure it's correctly validating the session's role value:
Adjust the role ID in the check if your project uses a different value for admin access.public function is_admin() { if($this->session->userdata('role') != 1) { redirect('user/login'); } } - Reset Sessions & Cache: Clear your browser's cache and delete all rows from the
ci_sessionstable to eliminate stale session data that might be causing conflicts.
Quick Validation Test
After making these changes:
- Re-enable the
profilemethod in the User controller. - Log out completely, then log back in with your admin credentials.
- Check if you can now access all sections like Expenses, Income, and Reports.
If you still run into issues, share the error logs from application/logs—that will help narrow down the exact problem faster.
内容的提问来源于stack exchange,提问作者Alshoja
相关产品推荐
相关产品推荐

