VuFind 1.x’s login followup logic is not pretty. Fortunately, this will improve in 2.0, and in the meantime, you can borrow the basic logic in order to achieve the effect you want. Here’s the algorithm I recommend for MyResearch/Home:
1.) If there is no followup URL in the session, store the HTTP referrer in the session. If there’s already a stored URL, do nothing – this prevents the problem you describe.
2.) Attempt the login process…
3.) If the login was successful, redirect the user to the stored followup URL in the session, then remove the value from the session to avoid confusion next time around. And, of course, if no value is found in the session, use the default (you need to account for this case, since referrer can be turned off at the browser level if a user is feeling uncooperative).
I hope this helps – let me know if you have any questions.
From: Stewart Brownrigg [mailto:S.J.Brownrigg@kent.ac.uk]
Sent: Tuesday, December 20, 2011 6:05 AM
Subject: [VuFind-Tech] On login, return user to referring page
I have been asked if it would be possible to return a user to the page they were on in VuFind (1.2) after they have logged on. Our KEVEN theme has the login form on every page, and users find it frustrating that they are taken to the default MyResearch page instead of the one they currently on.
I have tried capturing and using $_SERVER[‘HTTP_REFERER’] in My Research/Home.php which works ok - until a user gives incorrect login details. When this happens the details of the referring page are replaced with MyResearch/Home when presented with the login page again (and then goes into a loop when the user provides correct credentials).
I am looking for any advice from anyone that might have tried this, before I spend too much time on something that is difficult to implement.
Stewart J Brownrigg
Learning & Research Development, Information Services, University of Kent, Canterbury, Kent, CT2 7NF, UK
+44(0)1227 823621; S.J.Brownrigg@kent.ac.uk