Question

i have a login page on my mobile website as index.html so the user has to either login , which will take them to the main site, or register, which will let them register, and then login and gain access to the main site.

bit like a mobile app login page.

how can i block this page being accessed again by the user once they are logged in? as they can simply press the back button on their phones to go back to this page.

ideally i want if they try and access this index.php page once they are logged in to be redirected back to the home.php page.

started work on site here - http://m.cutecupcak.es

Was it helpful?

Solution 2

To build upon Jacob's answer.

Set a cookie or session upon logon and upset it upon logout.

In the index page. Check that the user is already logged in, and redirect the to the members page if they are.

Also it is a good idea to use the header function and disable caching of the page so that it is checked against the server every time.

OTHER TIPS

Use a session or cookie.

You would set the session upon the login and check your index.php page if the session is set or not.

Basic useage of a session

<?php
session_start();

// Set the session
$_SESSION["loggedin"] = "yes";

// Check if the session exists or doesn't, in this case, it does.
isset($_SESSION['loggedin']){
echo "You're logged in";
}else{
echo "You're not logged in";
}
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top