# Redirecting user after logging in

**URL:** <https://forum.getkirby.com/t/redirecting-user-after-logging-in/492>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 17, 2015, 10:24am UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492 "2015-03-17T10:24:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![swishlade](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/swishlade/32/313_2.png) [@swishlade](https://forum.getkirby.com/u/swishlade)\
**Post date:** [March 17, 2015, 10:24am UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492/1 "2015-03-17T10:24:35Z")

</div>

If I send a link to someone and they have to log in, once they have entered in their details and click ‘submit’ they are taken to the home page of the site. Is it possible once they have entered their details to continue to the page they were linked to originally rather than redirecting to the home page?

---

<div class="post-metadata">

**Author:** ![andi242](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/andi242/32/3132_2.png) [@andi242](https://forum.getkirby.com/u/andi242)\
**Post date:** [March 17, 2015, 10:40am UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492/2 "2015-03-17T10:40:30Z")

</div>

What you can do is write a form to login, post to $PHP\_SELF, check if the user is logged in and redirect.

Like this:

```
<? 
$user = site()->user();
if(!empty($user)) { 
	echo "you are logged in and being redirected.";
	sleep(3);
	go('home'); // or wherever...
} 
// do form stuff
?>
```

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [March 17, 2015, 7:25pm UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492/3 "2015-03-17T19:25:10Z")

</div>

You should look into `$_SERVER['REQUEST_URI']` and e.g. store that in a hidden input field, so that after the successful login you can retrieve the original wanted target and redirect the user there

---

<div class="post-metadata">

**Author:** ![criuz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/criuz/32/312_2.png) [@criuz](https://forum.getkirby.com/u/criuz)\
**Post date:** [March 21, 2015, 10:12pm UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492/4 "2015-03-21T22:12:38Z")

</div>

I am looking at the same issue right now. Have you been able to create a working example of a redirect to requested page after login?

---

<div class="post-metadata">

**Author:** ![zerotaste](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zerotaste](https://forum.getkirby.com/u/zerotaste)\
**Post date:** [June 20, 2015, 9:09am UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492/5 "2015-06-20T09:09:06Z")

</div>

@criuz

There some working examples in this thread

[http://forum.getkirby.com/t/authentication-private-pages-direct-urls/1401/4](http://forum.getkirby.com/t/authentication-private-pages-direct-urls/1401/4)

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:17pm UTC](https://forum.getkirby.com/t/redirecting-user-after-logging-in/492/6 "2025-02-06T17:17:10Z")

</div>

Archived on February 6, 2025, 5:17pm UTC


