如何解决会话数据以错误的访问者结尾?那怎么可能?
我们正面临一个网站问题。 一位准客户发现表格中已预先填充了另一位准客户的数据。
我们在一页上有4个联系表单,当联系人输入表单后,数据将保存在会话中。当他们返回时,表单将使用会话中的数据进行预填充。但是现在,我们从潜在客户那里获得了一个印刷屏幕,其中包含先前潜在客户的数据。
以下是该会话的代码:
//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');
解决方法
您是否检查过是否在缓存页面?这可能会导致类似的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。