2010-03-29 3 views
0

스크립트 끝에서 종료 함수로 session_write_close()를 사용하면 PHP가 종료됩니다. 로그 된 오류, 응답 헤더 (방화 광) 또는 데이터 (심지어 공백!)가 리턴되었습니다. STRICT가 활성화되어 있고 PHP 5.2.1이 설치된 경우 전체 PHP 오류를보고합니다.PHP session_write_close()로 인해 빈 응답이 발생합니다.

내 생각 엔 shutdown 후 session_write_close()가 호출 된 것입니다. 출력이나 로그를 보낼 기회가 있기 전에 PHP를 충돌시키는 치명적인 오류가 발생했습니다.

이는 어디 먼저 로그 아웃 페이지에 발생합니다

다음
... 
    //If there is no session to delete (not started) 
    if (! session_id()) 
    { 
     return; 
    } 

    // Get the session name 
    $name = session_name(); 

    // Delete the session cookie (if exists) 
    if (! empty($_COOKIE[$name])) 
    { 
     //Get the current cookie config 
     $params = session_get_cookie_params(); 

     // Delete the cookie from globals 
     unset($_COOKIE[$name], $_SESSION); 

     //Delete the cookie on the user_agent 
     setcookie($name, '', time()-43200, $params['path'], $params['domain'], $params['secure']); 
    } 

    // Destroy the session 
    session_destroy(); 
... 

2) 좀 더 많은 물건 3) 리디렉션을 발행하고 4) 마지막으로, 전체 페이지 후 앞서 배치 register_shutdown_function();을 수행 할 세션을 데이터베이스에 저장하는 session_write_close()를 호출하고 호출합니다. 끝.

이 비어있는 응답은 로그 아웃시에만 발생하기 때문에 세션 끝내기에 session_write_close()가 치명적으로 죽는 원인이되는 세션을 제대로 다시 시작하지 않는다고 생각합니다.

+0

왜 session_write_close()가 필요합니까? – zerkms

+0

일부 버전의 PHP에서 세션이 저장되었는지 확인하려면 생각합니다. – Xeoncross

+0

스크립트가 스크립트의 끝에 자동으로 닫히고 쓰여지고 있습니다. – zerkms

답변

0

이상. 문제는 내가 쿠키를 제거하기 전에 세션을 파괴하고 있다는 사실입니다.

이 작동 :

// Delete the session cookie (if exists) 
    if (! empty($_COOKIE[$name])) 
    { 
     //Get the current cookie config 
     $params = session_get_cookie_params(); 

     // Delete the cookie from globals 
     unset($_COOKIE[$name], $_SESSION); 

     //Delete the cookie on the user_agent 
     setcookie($name, '', time()-43200, $params['path'], $params['domain'], $params['secure']); 
    } 

    // Destroy the session ----------------------------------------- 
    session_destroy(); 

을이 페이지 죽이는 동안 :

// Destroy the session ----------------------------------------- 
    session_destroy(); 

    // Delete the session cookie (if exists) 
    if (! empty($_COOKIE[$name])) 
    { 
     //Get the current cookie config 
     $params = session_get_cookie_params(); 

     // Delete the cookie from globals 
     unset($_COOKIE[$name], $_SESSION); 

     //Delete the cookie on the user_agent 
     setcookie($name, '', time()-43200, $params['path'], $params['domain'], $params['secure']); 
    } 

사람이 왜 알고 있나요을?

관련 문제