簡體   English   中英

高流量如何導致“會話ID太長或包含非法字符”

[英]How can heavy traffic cause “The session id is too long or contains illegal characters”

在我位於HostGator上的共享主機上的網站上,幾天前,我開始在流量繁忙的時候收到錯誤500(那天249次訪問,148,429次點擊,141,829頁,723.01 MB帶寬-許多人在訪問MySQL查詢。)托管,HostGator一次僅允許25個正在運行的進程。 一旦流量減少,錯誤就消失了。

但是,當我訪問那個時間和日期的錯誤日志時,這就是我發現寫過很多遍的內容:

[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

我不明白的是,錯誤“會話ID太長或包含非法字符”是由繁忙的流量引起的嗎? 會話ID字符與繁忙的流量有什么關系?

目前,該網站運行正常。 我還訪問了Stackoverflow上的Question ,但是它沒有解釋錯誤,只是給出了解決方法。 請解釋為什么只有在交通繁忙時才出現此錯誤。 我想確保我的代碼正確。

以下是我所有PHP頁面在網站上的啟動方式:

<?php
session_start();
require_once("user.cookies.php");

$username = $_SESSION["SESS_USERNAME"];
$id= $_SESSION["SESS_USERID"];

這是user.cookies.php

<?php

//redirect function
function returnheader($location){
    $returnheader = header("location: $location");
    return $returnheader;
}

if(!strlen($_SESSION["SESS_USERNAME"]) ){

    //redirect
    returnheader("login.php");
}

?>

正如這個問題中提到的

(...)將您鏈接到生成的會話ID的cookie是客戶端。 如果該cookie更改為無效格式(有人試圖利用某些東西),PHP將注意到它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM