Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, you should never rely on a GET variable (or even a hidden POST variable) to say, "sure, let me in, I'm a valid user!".</p> <p>Personally, I would strip the GET information from the link and rely solely on session variables. Remember to place a 'session_start();' as the first line of code if you are using PHP to activate the session.</p> <p>For submit.php:</p> <pre><code>&lt;?php session_start(); if ($_POST['user'] &amp;&amp; $_POST['pass']) { // Make sure both variable are set if (your_method) { // Code to check if the user and pass are valid however you plan $_SESSION['user'] = $_POST['user']; $_SESSION['loggedin'] = time(); } } header('Location: form.php'); // Either way, pass or fail, return to form.php exit(); ?&gt; </code></pre> <p>Then in form.php:</p> <pre><code>&lt;?php session_start(); $activeuser = false; if ($_SESSION['user'] &amp;&amp; $_SESSION['loggedin'] &lt; (time()+600)) { // Check if the user exists and the last access was with in 10 minutes. $_SESSION['loggedin'] = time(); // If so, keep them up to date! $activeuser = true; } if ($activeuser) { // whatever should show to someone logged in } else { // Show log in form } ?&gt; </code></pre> <p>Also, you may already know this, but the default method of transferring is GET, so be sure to specify method="post" in the form tag.</p> <p>It's normally best to use header() to redirect if needed as Javascript is client-side and can be avoided which can break your intent for the functioning of your site.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload