Welcome Guest, Not a member yet? Register   Sign In
Multiple applications & post-login redirection
#1

[eluser]danphilibin[/eluser]
I'm trying to write a simple function for my login function that takes the user to where they intended to go after they login. It's just like WordPress or a lot of other CMSs do - if I try to access a private page and need to log in first, after I login I'm taken to that page.

Anyway, my site uses two applications: 'account' (back-end) and 'main_site' (default & front-end). When I use either <code>$this->uri->uri_string()</code> or <code>current_url()</code> to detect where the user should go, both of those functions aren't returning the application name. I think it's because of how htaccess is setting up my applications, but I'm not sure.

The URL I want is http://mydomain.com/application_name/seg1/seg2, but what I'm getting is http://mydomain.com/seg1/seg2. How can I get the full URL to send to my function?

Thanks!
#2

[eluser]Mischievous[/eluser]
Do this with .htaccess file and seperate index.php files in the root directory. One index.php (main_site.php) would direct to the front end application the second index.php (account.php) would goto the backend application. Then if you want to login from the frontend have it redirect to the backend index
#3

[eluser]danphilibin[/eluser]
Hmm, I'm not sure that answers my question. I have two files in the root, index.php and account.php, for the two applications, and htaccess sets that up. Logging in isn't the problem, it's how CI is returning the URLs that is the problem.
#4

[eluser]Mischievous[/eluser]
The problem lies when calling the $this->uri->uri_string()? ... If thats the case setup a custom function that gets the URI from $_SERVER ??? Wouldn't that work?
#5

[eluser]skunkbad[/eluser]
The entire user authentication system of Community Cart is an example of what you are asking about. If the user goes to a page and is not logged in, it makes them log in. Once successfully logged in, they end up at the page they were trying to go to.
#6

[eluser]danphilibin[/eluser]
Sorry, I haven't used Community Cart before. I dug around in the code, but I couldn't find anything. It seems like the login form is outputted on any protected page, where in my application, if a user isn't logged in I'm redirecting to the same page, 'account/login', that has the form. That method seems easier to do because you either show the login page or the regular page instead of having to set up redirections, but I prefer to have my form at one URL. I can set it up the other way if needed, I was just wondering if there was a way to go about doing it my way.
#7

[eluser]skunkbad[/eluser]
[quote author="danphilibin" date="1273170372"]Sorry, I haven't used Community Cart before. I dug around in the code, but I couldn't find anything. It seems like the login form is outputted on any protected page, where in my application, if a user isn't logged in I'm redirecting to the same page, 'account/login', that has the form. That method seems easier to do because you either show the login page or the regular page instead of having to set up redirections, but I prefer to have my form at one URL. I can set it up the other way if needed, I was just wondering if there was a way to go about doing it my way.[/quote]

Yes, you are correct. I don't know how you would do it another way. I worked on my auth system for many many hours, so it's not something to tell you how to do in a simple forum post.




Theme © iAndrew 2016 - Forum software by © MyBB