Question

I am writing an application in CodeIgniter and I have concluded that it's best to write two applications. One for back office and one for client use.

I would like to have just one login screen. It will be in the back office application but if a client user logs in then I want to redirect to the client app and create a session there. The database user table stores the user type i.e. client or admin.

I have come up with the following solution. As I want to this the correct way I said i'd run it by you guys to see what ye think.

  • User logs into admin CI app.
  • Admin CI app verifies user and determines type. If admin then go ahead and create session etc.
  • If the user is a client then MD5(user_ip+timestamp OR make a secure token some other way) and store in a token field (user_table) in DB.
  • redirect the user to the client admin via a login page. The paramters would be the token and username. The login function would then go to that user in the database and verify the token.
  • On successful authorization of token the CI client app would start a session and let the user in.

This seems like a very long winded method. Ideally there would be a way to start a session for one CI app from another?

Any ideas?

Thanks.

Was it helpful?

Solution

I would go about making 2 applications under HMVC (Hierarchical-Model-View-Controller) framework.

HMVC CodeIgniter Tutorial

Then you can go about using same sessions under multiple applications, as well as use the same models for user management, etc..

HMVC helps you modularize your applications, thus if you want to add more applications in the future, you can easily do that, passing over same sessions and such.

I answered your question in a bigger scope, one central login with 2 apps, best should be done with HMVC.

:)

OTHER TIPS

Once you've verified admin or client, I would use the CodeIgniter session class with the ci_sessions table in your database.

http://codeigniter.com/user_guide/libraries/sessions.html

Then to distinguish users from client or employee add a variable to the session.

$this->session->set_userdata('user_type', 'client');

Then just use that if ever you need it.

Might wanna check out BackEndPro for CodeIgniter, could save you a lot of time.

Includes:

  • User Authentication with registration & account activation
  • User Permissions by using ACL (Access Control Lists)
  • Admin GUI backend for editing Site-wide Preferences
  • Built on Matchbox (for Modular development)
  • Asset Library (optimize, cache, and load JS & CSS)
  • ReCAPTCHA
  • Status messages (info/success/warning/error messages for the user)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top