neufelni Posted July 26, 2008 Share Posted July 26, 2008 Hello everyone, I am making a website which requires users to login, however, I am often getting the following error when logging in: Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\TCP\pages\Users\Authenticate.php on line 28 Here is the code in Authenticate.php that causes the error: if (md5($_POST["Password"]) == $password) { session_start(); $_SESSION['logged_in'] = true; header('Location: ../Administration/index.php'); } else header('Location: login.php?result=0'); Line 28, the line where the error occurs is: $_SESSION['logged_in'] = true; About half the time it logs in just fine, but the other half I get the error. This error only occurs when the username and password is correct, if it is incorrect it returns to the login page just fine. Does anyone know what could cause this? Thanks, neufelni Link to comment https://forums.phpfreaks.com/topic/116720-problem-creating-session/ Share on other sites More sharing options...
JasonLewis Posted July 26, 2008 Share Posted July 26, 2008 session_start() should always be at the top of the page. Link to comment https://forums.phpfreaks.com/topic/116720-problem-creating-session/#findComment-600153 Share on other sites More sharing options...
PFMaBiSmAd Posted July 26, 2008 Share Posted July 26, 2008 You won't get an execution time limit error due to the posted code. You must have a loop of some kind that never exits. Post all your code to get the quickest answer. Also, depending on what code is after the posted lines of code, you need to put an exit; statement after any header() redirect. Link to comment https://forums.phpfreaks.com/topic/116720-problem-creating-session/#findComment-600295 Share on other sites More sharing options...
unidox Posted July 26, 2008 Share Posted July 26, 2008 Can we also see index.php, I think there might be a loop. Link to comment https://forums.phpfreaks.com/topic/116720-problem-creating-session/#findComment-600376 Share on other sites More sharing options...
neufelni Posted July 27, 2008 Author Share Posted July 27, 2008 Hello, thanks for the replies. I moved session_start to the top of the page, but am still getting this error. Here is the entire Authenticate.php file. <?php session_start(); ini_set("display_errors","2"); ERROR_REPORTING(E_ALL); function __autoload($class_name) { require_once("../../Models/" . $class_name . '.php'); } if (!ISSET($_POST["Username"]) || !ISSET($_POST["Password"])) header('Location: login.php'); $db = new DBConnection(); $query = SQLStatements::SelectPasswordByUserName($_POST["Username"]); $query = mysql_query($query); $password = NULL; while ($row = mysql_fetch_array($query)) { $password = $row[0]; } if (md5($_POST["Password"]) == $password) { $_SESSION['logged_in'] = true; header('Location: ../Administration/index.php'); } else header('Location: login.php?result=0'); ?> I don't think the index.php file has anything to do with it, since the error says that it occurred in Authenticate.php, and it doesn't begin to load index.php(the address bar remains at Authenticate.php). Also, occasionally I just get a server not responding message instead, like this: Safari could not open the page “http://tcp.homeip.net:8080/tcp/pages/Users/Authenticate.php” because the server is not responding. Once again, it occurs when loading Authenticate.php. This problem seems to only occur when I'm running the site from the server where I am currently testing it. I have never had it occur when running it one my local machine. And since the line where it says that the error occurs is $_SESSION['logged_in'] = true; I think it might be a problem with some configuration on the server that's not allowing it to create a session. That's the only thing that makes sense to me. Any ideas? Thanks, neufelni Link to comment https://forums.phpfreaks.com/topic/116720-problem-creating-session/#findComment-600612 Share on other sites More sharing options...
samshel Posted July 27, 2008 Share Posted July 27, 2008 this code too doesnt look like causing any time limit problems..as PFMaBiSmAd suggestd you can put exit after every header redirect.. the problem may be because of __autoload function, try including all files manually. just to check. Link to comment https://forums.phpfreaks.com/topic/116720-problem-creating-session/#findComment-600693 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.