# Redirect to url after login

**URL:** <https://forum.getkirby.com/t/redirect-to-url-after-login/14169>\
**Category:** Questions\
**Tags:** v3\
**Created:** [May 10, 2019, 11:37am UTC](https://forum.getkirby.com/t/redirect-to-url-after-login/14169 "2019-05-10T11:37:52Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![sebastiangreger](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sebastiangreger/32/16176_2.png) [@sebastiangreger](https://forum.getkirby.com/u/sebastiangreger)\
**Post date:** [March 11, 2022, 11:14am UTC](https://forum.getkirby.com/t/redirect-to-url-after-login/14169/20 "2022-03-11T11:14:37Z")

</div>

> [@Adrieng](#):
>
> I want to redirect to a variable url

That should be possible by using a custom site method. We had a discussion around such a use case a little while ago, maybe that can serve as an inspiration:

> [@Remember requested path in session via controller](https://forum.getkirby.com/t/remember-requested-path-in-session-via-controller/24382/18):
>
> I just gave this a try on the develop branch with the upcoming changes for 3.6.2 and it worked flawlessly. Here’s what I did; maybe this helps tracking down where your approach runs into that error? 1 – Created a route for login/(:all), but that’s of course just one of many ways to set the logintarget in the session: // in config.php -\> routes [ 'pattern' =\> 'login/(:all)', 'action' =\> function ($path = null) { kirby()-\>session()-\>set('myplugin.logintarget', $path); go(…

In a nutshell: You can set the `home` option to call a custom site method (e.g. `home: "{{ site.logintarget }}"`), where the site method `logintarget` should return the desired URL. In my solution for that specific scenario, I store the variable URL in the Kirby session, but you could of course use any other source for that URL to be returned.

---

_[View the full topic](https://forum.getkirby.com/t/redirect-to-url-after-login/14169)._
