On my website on shared hosting on HostGator, few days back I started getting error 500 during the time of heavy traffic ( 249 visits, 148,429 hits, 141,829 pages, 723.01 MB Bandwidth on that day - many people were hitting MySQL queries. And on shared hosting, HostGator only allows 25 running processes at the time). As soon as the traffic decreased, the errors disappeared.
But when I accessed the error logs of that time and day, this is what I found written many times:
[12-Oct-2014 16:37:16] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in /home/amalthea/public_html/tkq/q0.php on line 2
[12-Oct-2014 16:37:16] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home/amalthea/public_html/tkq/q0.php:2) in /home/amalthea/public_html/tkq/q0.php on line 2
[12-Oct-2014 16:37:16] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/amalthea/public_html/tkq/q0.php:2) in /home/amalthea/public_html/tkq/q0.php on line 2
[12-Oct-2014 16:37:16] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/amalthea/public_html/tkq/q0.php:2) in /home/amalthea/public_html/tkq/user.cookies.php on line 5
What I don't understand is, how the error "The session id is too long or contains illegal characters" was caused by heavy traffic? What has heavy traffic got to do with session id characters?
Currently, the site is working fine. I also visited this Question on Stackoverflow, but it does not explain the error, it only gives a work-around. Please explain why I got the error ONLY under heavy traffic. I want to make sure that my code is correct.
Below is how all my PHP pages start on the site:
<?php
session_start();
require_once("user.cookies.php");
$username = $_SESSION["SESS_USERNAME"];
$id= $_SESSION["SESS_USERID"];
And here is user.cookies.php
<?php
//redirect function
function returnheader($location){
$returnheader = header("location: $location");
return $returnheader;
}
if(!strlen($_SESSION["SESS_USERNAME"]) ){
//redirect
returnheader("login.php");
}
?>