Note that there are some explanatory texts on larger screens.

plurals
  1. POWhats wrong with this php code, keep getting Error no 2?
    primarykey
    data
    text
    <pre><code>&lt;?php session_start(); // After user logged in session_regenerate_id(); $_SESSION['logged_in'] = 1; $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; $_SESSION['agent'] = $_SERVER['HTTP_USER_AGENT']; // Session Checking function session_check(){ if(isset($_SESSION['logged_in']) &amp;&amp; !empty($_SESSION['logged_in'])){ if(isset($_SESSION['ip']) &amp;&amp; !empty($_SESSION['ip']) &amp;&amp; ($_SESSION['ip'] == $_SERVER['REMOTE_ADDR'])){ if(isset($_SESSION['agent']) &amp;&amp; !empty($_SESSION['agent']) &amp;&amp; ($_SESSION['agent'] == $_SERVER['HTTP_USER_AGENT'])){ return true; } else { echo "Not allowed to view this page. Error no: 3. You will be redrected to login page in few seconds"; header('Refresh: 3; url=./login.php'); } } else { echo "Not allowed to view this page. Error no: 2. You will be redirected to login page in few seconds"; header('Refresh: 3; url=./login.php'); } } else { echo "You are not allowed to view this page. Error no: 1. You will be redirected to login page in few seconds"; header('Refresh: 3; url=./login.php'); return false; } } </code></pre> <p>And I keep getting error no2 when I run:</p> <pre><code>if(session_check()){ echo "something";} </code></pre> <p>Is it because I am using dynamic IP?</p> <p><strong>Is my code good enough to protect session hijacking?</strong></p> <p>If I exclude the <code>($_SESSION['ip'] != $_SERVER['REMOTE_ADDR'])</code>, it works perfectly.</p> <p><strong>Important Question:</strong></p> <p>What are your anti session hijacking methods? Can share with us? Using IP-checking, user-agent checking or probably other methods??</p>
    singulars
    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.
 

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