我試圖在php會話中存儲大量POST數據。數據似乎保存沒有任何問題,但是當我嘗試訪問下一頁加載的數據時,它未被設置。我不知道我在做什麼錯。這是最小工作實例,我可以使:會話變量未設置
的index.php<?php
session_start();
$_SESSION['roles'] = $_POST['ext_roles'];
var_dump($_SESSION);
session.php文件
<?php
session_start();
var_dump($_SESSION);
當我讓POST到index.php
,示出了數據按預期:
/var/www/default/index.php:4:
array (size=1)
'roles' => string '00000000000000000' (length=17)
,但是當我加載session.php
,我得到這個:
/var/www/default/session.php:3:
array (size=1)
'roles' => null
它不會發生在所有的數據,只是我真正關心的數據。如果我只是使用郵遞員提交隨機POST數據,它的工作方式與預期的一樣,但從我試圖保存的外部源進入初始POST的數據始終設置爲null或空數組。我在這裏完全失敗。
這裏是我試圖與會話持久化表單數據:
form.html
<html>
<body>
<form action="index.php" method="post">
<input type="hidden" name="oauth_consumer_key" value="00000000000000000"/>
<input type="hidden" name="oauth_signature_method" value="00000000000000000"/>
<input type="hidden" name="oauth_timestamp" value="00000000000000000"/>
<input type="hidden" name="oauth_nonce" value="00000000000000000"/>
<input type="hidden" name="oauth_version" value="00000000000000000"/>
<input type="hidden" name="context_id" value="00000000000000000"/>
<input type="hidden" name="context_label" value="00000000000000000"/>
<input type="hidden" name="context_title" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_api_domain" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_assignment_id" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_assignment_points_possible" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_assignment_title" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_course_id" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_enrollment_state" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_user_id" value="00000000000000000"/>
<input type="hidden" name="custom_canvas_user_login_id" value="00000000000000000"/>
<input type="hidden" name="ext_ims_lis_basic_outcome_url"
value="00000000000000000"/>
<input type="hidden" name="ext_outcome_data_values_accepted" value="00000000000000000"/>
<input type="hidden" name="ext_outcome_result_total_score_accepted" value="00000000000000000"/>
<input type="hidden" name="ext_outcomes_tool_placement_url"
value="00000000000000000"/>
<input type="hidden" name="ext_roles"
value="00000000000000000"/>
<input type="hidden" name="launch_presentation_document_target" value="00000000000000000"/>
<input type="hidden" name="launch_presentation_locale" value="00000000000000000"/>
<input type="hidden" name="launch_presentation_return_url"
value="00000000000000000"/>
<input type="hidden" name="lis_course_offering_sourcedid" value="00000000000000000"/>
<input type="hidden" name="lis_outcome_service_url"
value="00000000000000000"/>
<input type="hidden" name="lis_person_contact_email_primary" value="00000000000000000"/>
<input type="hidden" name="lis_person_name_family" value="00000000000000000"/>
<input type="hidden" name="lis_person_name_full" value="00000000000000000"/>
<input type="hidden" name="lis_person_name_given" value="00000000000000000"/>
<input type="hidden" name="lis_person_sourcedid" value="00000000000000000"/>
<input type="hidden" name="lti_message_type" value="00000000000000000"/>
<input type="hidden" name="lti_version" value="00000000000000000"/>
<input type="hidden" name="oauth_callback" value="00000000000000000"/>
<input type="hidden" name="resource_link_id" value="00000000000000000"/>
<input type="hidden" name="resource_link_title" value="00000000000000000"/>
<input type="hidden" name="roles" value="00000000000000000"/>
<input type="hidden" name="tool_consumer_info_product_family_code" value="00000000000000000"/>
<input type="hidden" name="tool_consumer_info_version" value="00000000000000000"/>
<input type="hidden" name="tool_consumer_instance_contact_email" value="00000000000000000"/>
<input type="hidden" name="tool_consumer_instance_guid"
value="00000000000000000"/>
<input type="hidden" name="tool_consumer_instance_name" value="00000000000000000"/>
<input type="hidden" name="user_id" value="00000000000000000"/>
<input type="hidden" name="user_image"
value="00000000000000000"/>
<input type="hidden" name="oauth_signature" value="00000000000000000"/>
<button type="submit" name="submitButton">Go</button>
</form>
</body>
</html>
是什麼樣的數據呢?刪除了一個。給我們一個樣本。 –
我看到的一件事情可能會導致這種情況,一開始就是'session_unset()'。這將意味着它再次被調用''session.php'的負載,但是這可能導致這種情況。 – Nytrix
@Nytrix我嘗試過,沒有'session_unset()'。真正的代碼中沒有'session_unset()'。 –