Redirect to Referring Page after Login

By Perchpole - December 3, 2012

Hello, All -

I'm not sure whether this should go here or in the plugin dept - so pleas forgive me if I've got it wrong.

I want to explore the possibilities for redirecting users after they login. The current options are pretty static and have led to complaints from both customers and users.

The main issue concerns redirection once a user has logged in.

In my particular scenario, a user could come from any number of different pages to the main login page.

Once logged in, however, I need the user to be returned to the referring page.

The websiteMembership.php file doesn't provide an awful lot of options here! So I tried to create a "go back" button which the user could click on to send them back to the referring page.

I tried experimenting with HTTP_REFER, et al, but this doesn't work as expected. Once a user has a arrived at the login page, and then logs in, the referring page IS the login page!

I've seen examples using $_SESSIONS but I don't know if this would make things overly complex.

Any advice would be most welcome.

:0)

Perch

Re: [greg] Redirect to Referring Page after Login

By Perchpole - December 3, 2012

Hi, Greg -

Thanks for this. It's perfect and so simple!

All those hours I wasted searching the internet......!

;0)

Perch