I have a login script using sessions and it checks that a user is logged in at the start of each page:
Its very simple and all but it works fine for now. I know it isn't secure but can't do that until the problems are ironed out.
However when my friend attempts to log in from his flat it seems that the session is not able to start.
Using his same machine with no changes he was able to use it fine from home but when he is behind a wireless router at his flat it doesn't work.
I am wondering how I can get the same effect (ensuring people are logged in) when users are behind a router.
I can't expect users to change hardware settings just for me so there must be a workaround as he is able to use other sites which I assume use sessions or something similar (hotmail etc.)
If anyone could even identify the problem that would be handy so I can come up with a solution.
David.
| Code: |
|
session_start(); if (isset($_SESSION['user_id'])) { // connect to MySQL mysql_connect("host", "user", "pass"); // try and open game database $result = mysql_select_db("database"); // Report error if no database if ($result != true){ print "No database!"; exit("<p><a href=\"index.php\">Back to menu</a>"); }//endif } else{ print "Please log in first."; exit("<p><a href=\"index.php\">Back to menu</a>"); } $user_id=$_SESSION['user_id']; |
Its very simple and all but it works fine for now. I know it isn't secure but can't do that until the problems are ironed out.
However when my friend attempts to log in from his flat it seems that the session is not able to start.
Using his same machine with no changes he was able to use it fine from home but when he is behind a wireless router at his flat it doesn't work.
I am wondering how I can get the same effect (ensuring people are logged in) when users are behind a router.
I can't expect users to change hardware settings just for me so there must be a workaround as he is able to use other sites which I assume use sessions or something similar (hotmail etc.)
If anyone could even identify the problem that would be handy so I can come up with a solution.
David.
