会话数据以错误的访客结束?这怎么可能?
Session data ends with wrong visitor? How is that possible?
我们遇到了网站问题。
一位潜在客户注意到表格中预填了来自另一位潜在客户的数据。
我们在一个页面上有 4 个联系人表单,当联系人输入表单时,数据将保存在会话中。当他们 return 时,表格会预先填充会话中的数据。但是现在我们从一个潜在客户那里得到了一个打印屏幕,其中包含以前一个潜在客户的数据。
这是会话的代码:
//This will start a session, then save the posted_data[something] to the session
add_action('init', 'myStartSession', 1);
add_action('wp_logout', 'myEndSession');
add_action('wp_login', 'myEndSession');
function myStartSession() {
if ( empty( $_SESSION ) ) {
session_start();
}
}
function myEndSession() {
session_destroy ();
}
function set_sessions($cf7){
/* Use WPCF7_Submission object's get_posted_data() method to get it. */
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
$_SESSION['formdata']['firstname'] = $posted_data['firstname'];
$_SESSION['formdata']['lastname'] = $posted_data['lastname'];
$_SESSION['formdata']['email2'] = $posted_data['email2'];
$_SESSION['formdata']['tel'] = $posted_data['tel'];
$_SESSION['formdata']['postcode'] = $posted_data['postcode'];
$_SESSION['formdata']['adres'] = $posted_data['adres'];
return false;
}
add_action( 'wpcf7_before_send_mail', 'set_sessions' );
function firstname(){
return $_SESSION['formdata']['firstname'];
}
add_shortcode('firstname', 'firstname');
function lastname(){
return $_SESSION['formdata']['lastname'];
}
add_shortcode('lastname', 'lastname');
function email2(){
return $_SESSION['formdata']['email2'];
}
add_shortcode('email2', 'email2');
function tel(){
return $_SESSION['formdata']['tel'];
}
add_shortcode('tel', 'tel');
function postcode(){
return $_SESSION['formdata']['postcode'];
}
add_shortcode('postcode', 'postcode');
function adres(){
return $_SESSION['formdata']['adres'];
}
add_shortcode('adres', 'adres');
您检查过是否缓存了页面吗?这可能会导致类似的问题。
我们遇到了网站问题。 一位潜在客户注意到表格中预填了来自另一位潜在客户的数据。
我们在一个页面上有 4 个联系人表单,当联系人输入表单时,数据将保存在会话中。当他们 return 时,表格会预先填充会话中的数据。但是现在我们从一个潜在客户那里得到了一个打印屏幕,其中包含以前一个潜在客户的数据。
这是会话的代码:
//This will start a session, then save the posted_data[something] to the session
add_action('init', 'myStartSession', 1);
add_action('wp_logout', 'myEndSession');
add_action('wp_login', 'myEndSession');
function myStartSession() {
if ( empty( $_SESSION ) ) {
session_start();
}
}
function myEndSession() {
session_destroy ();
}
function set_sessions($cf7){
/* Use WPCF7_Submission object's get_posted_data() method to get it. */
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
$_SESSION['formdata']['firstname'] = $posted_data['firstname'];
$_SESSION['formdata']['lastname'] = $posted_data['lastname'];
$_SESSION['formdata']['email2'] = $posted_data['email2'];
$_SESSION['formdata']['tel'] = $posted_data['tel'];
$_SESSION['formdata']['postcode'] = $posted_data['postcode'];
$_SESSION['formdata']['adres'] = $posted_data['adres'];
return false;
}
add_action( 'wpcf7_before_send_mail', 'set_sessions' );
function firstname(){
return $_SESSION['formdata']['firstname'];
}
add_shortcode('firstname', 'firstname');
function lastname(){
return $_SESSION['formdata']['lastname'];
}
add_shortcode('lastname', 'lastname');
function email2(){
return $_SESSION['formdata']['email2'];
}
add_shortcode('email2', 'email2');
function tel(){
return $_SESSION['formdata']['tel'];
}
add_shortcode('tel', 'tel');
function postcode(){
return $_SESSION['formdata']['postcode'];
}
add_shortcode('postcode', 'postcode');
function adres(){
return $_SESSION['formdata']['adres'];
}
add_shortcode('adres', 'adres');
您检查过是否缓存了页面吗?这可能会导致类似的问题。