Welcome Guest, Not a member yet? Register   Sign In
Sharing User Library and Session between 2 applications
#1

[eluser]eokorie[/eluser]
Is there a way I can share a user library between 2 applications? I do know a user session is shared between applications as I am able to view the dump user session data in my frontend and backend app.

I am trying to use an if logged in code for the site. At the moment, all users can login through the frontend and i have a link that loads the admin panel if an admin is logged in. I am however trying to restrict access to the backend to just an admin. Seeing that I have 2 applications, how do I get the backend to make use of the user library at the frontend? Or do I just replicated the user library in the admin backend?

Hope I am making sense..

Thanks
#2

[eluser]WanWizard[/eluser]
Don't know exactly what you mean by 'sharing the user library'.

Are you talking about two separate CI applications (with their own applications directory) that are sharing the same database (otherwise you wouldn't be able to access the session)?

In CI 1.7.2, the only option is to have the library available in both applications. You can also use a modular solution, and load the user library from the module directory that both applications share. If you use CI 2.0, you can install the user library as a 3rd party library, and load it from both application by adding it as a package.
#3

[eluser]eokorie[/eluser]
Hi WanWizard,

In effect I am trying to my auth library for a front end and backend. I may just have to start use CI2.0 and probably follow your idea.
#4

[eluser]bretticus[/eluser]
Are your front-end and back-end sites in the same virtual host or same domain (not separate subdomains?) If so, it depends on whether you're using sessions in some way. I'm not sure about CI's Session class and whether it distinguishes between application points or not. But essentially, sessions are cookie based. You always have, at least, a cookie token (session id.) Since cookies are domain specific, cookies can be shared over different applications in theory as long as they reside in the same virtual host (same domain.)

As @WanWizard pointed out, you will have to have a seperate (but identical) copy of your auth library under each application (because this is code specific in this case.)

If you want to try some simple hacking, I did provide some suggestions to another user how you might go about sharing libraries across applications.




Theme © iAndrew 2016 - Forum software by © MyBB