# Header function or redirect using PHP?

**URL:** <https://forum.kirupa.com/t/header-function-or-redirect-using-php/125772>\
**Category:** Uncategorized\
**Created:** [October 17, 2004, 2:14pm UTC](https://forum.kirupa.com/t/header-function-or-redirect-using-php/125772 "2004-10-17T14:14:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![samba\_7](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@samba\_7](https://forum.kirupa.com/u/samba_7)\
**Post date:** [October 17, 2004, 2:14pm UTC](https://forum.kirupa.com/t/header-function-or-redirect-using-php/125772/1 "2004-10-17T14:14:26Z")

</div>

If a user goes to a page that they have not logged into(using stored session variables) what is the coding involved to redirect them to the login page?

if ($redirect)  
{change this page to login}  
else  
{allow access to this page}

I’ve looked at the header(“location: url to be entered”) which is supposed to be the first thing on the page, then I know there is a redirect (just never seen the coding for it (I bet it is something simple)

thanks.

Sam.
