Welcome Guest, Not a member yet? Register   Sign In
[solved] How to write the current URL into a session (Comfort-Login)
#1

[eluser]tschunde[/eluser]
Hi all :-)

In order to bring a little comfort into the login part of my application I want to do the following:


Step 1. A guest visits a protected page (he needs to be logged insave the current URL the user visits into the session).
Step 2. The user is redirected to a login page while the url he wanted to view is saved into a session.
Step 3. After logging in the user is redirected to the protected page he wanted to visit last time.


On protected Controller Functions I make this call:
$this->acl->check(); //My Own ACL Class that checks if the user is logged in. If not he is redirected to login.
So I want to modify check() to save the current url into the session in order to redirect back after logging in.

How realize this this?

Kind Regards
tschunde
#2

[eluser]Kinsbane[/eluser]
FIrst, use this function combined with your $config('base_url') value to get the URL (unless there's a better way, which there probably is):
Code:
$this->uri->uri_string()

Then, use this to set the value into the session:
Code:
$this->session->set_userdata('some_name', 'some_value');
#3

[eluser]wiredesignz[/eluser]
You can read this thread http://ellislab.com/forums/viewthread/74855/ and then try a forum search.

Welcome to CI forums
#4

[eluser]tschunde[/eluser]
Whoa! You guys are really fast! Thank you very much...

I already did some searches but didn't find this thread.
I think now I'm gonna make it...
Great support Smile
#5

[eluser]tschunde[/eluser]
okay I implemented it now Smile
nice... works like a charm




Theme © iAndrew 2016 - Forum software by © MyBB