Welcome Guest, Not a member yet? Register   Sign In
Recording a user's last viewed page
#1

[eluser]KeyStroke[/eluser]
Hi,

I'm just wondering what's the best way to record a user's last visited page?

Shall I use $_SERVER['HTTP_REFERRER']? save every page he visits in a session? or how exactly?

It's needed when, for example, a user tries to use a member-only feature, then gets redirected to the login page to enter his login credintials, and then redirected back to the last page he was viewing.

Appreciate your help
#2

[eluser]Krzemo[/eluser]
I'd do it using sessions class and flashdata. Just save controller name before possible redirect to auth, keep it for one or two more requests if needed and redirect back to it when logged in.
#3

[eluser]KeyStroke[/eluser]
You mean I should save to a session in every controller's constructor?
#4

[eluser]Krzemo[/eluser]
Basically yes.
This is how I do it in my last app, but I have one main entry point to members area so I do it only in one controller.
#5

[eluser]jedd[/eluser]
[quote author="KeyStroke" date="1235835238"]You mean I should save to a session in every controller's constructor?[/quote]

You could extend the system controller (the recently discovered - by me - MY_Controller in the library approach Smile and have that push the flash data into the session data. Flashdata in Sessions page of the user guide.

This would still be fairly elegant, I think.




Theme © iAndrew 2016 - Forum software by © MyBB