Going back to the same page after logging in

I am using a site with loads of gated content.

But anytime I get a users to login, it would be great to return them to the page they just come from.

Has anyone got this setup and also is this something we could implement in the core as its something I come across all the time.

I made an add-on for this a while ago and still in use on a couple sites running 9.2.8.
Will look for package and post here later.


I also see it mentioned on this page

but that isn’t in the back end so whats that about? @andrew @frz @EvanCooper

Cannot upload here zip file here. Will have to pm u.

Just emailed u the zip file through your website.

Thanks @Steevb do i just drop it on a page?

I place it in a global area in the footer, see ‘Member Login’ on this site: [https://thundridge.org/]

@TMDesigns you can see it here: /system/registration/postlogin

Also, if you want to use code to redirect, check out Concrete\Core\User\PostLoginLocation | ConcreteCMS API

And here’s how it’s used in the core login singe page: concretecms/concrete/controllers/single_page/login.php at b17697307b735fd0d3953236f34ef6a4d366c757 · concretecms/concretecms · GitHub

@TMDesigns: I don’t see ‘Login Destination’, ‘Configuration’, ‘Dynamic Redirection’ either?

@Myq: I think Tim wants redirect back to the page a user logs in on?

If you look at the docs, it’s suggests this is in the core but it isn’t.

@TMDesigns I can change the wording for the dynamic redirection because this is sort of the default behavior. The custom redirection is the option to redirect to a specific page.

If you have a page that’s only visible to registered users, and a guest visits it, they will be directed to login and upon successful login, will be redirected to the original page. I just verified this works. There may be some issues if you’re using a different authentication type or something.

You can see an example of some gated content here: Login :: test

Log in with user1 and password and you’ll be redirected to that page.


@Myq you are wrong.the options are there in my image above.

I have content on a page that you can only see if you login if you are a guest it has a button that takes you to the login page, but it’s after that :heart: want to come back to that original page.

I am using this on about 50 different pages.

@Steevb has given me block and it’s working perfectly well, just wondering why there isn’t an option to go back to the original page like the documentation says.

This page is an example of use case, if you were to hit the login link at the bottom you wouldn’t come back to this page you would be redirected to somewhere else on the site.

@enlil: No disrespect concerning the ‘Login/Logout’ block, just think its a tad overkill. My block is very basic but functional, I will look at putting it back up for the mp for free (if it gets approved?).

1 Like

I’ve edited the page to better match the existing options.

1 Like

If you’re using a link to the login page to take your user there simply add /forward/cid_of_the_return_page to your link

I am actually using this on links

<?php echo URL::to('/login','forward', $c->getCollectionID())?>

the URL::to() has some great uses