php - 如何将 JQuery 值发送到 php SESSION
问题描述
我尝试将 JQuery 值发送到 SESSION,这是代码(MVC)
$(document).ready(function(){
$("#tbody th").click(function(){
var id = this.id;
$("#"+id).focus();
$("#send").val(id);
});
});
在 HTML 中:(form.php)
<form action="edit.php" method="post">
<input type="submit" name="choix" value="retour">
<input type="hidden" id="send" name="send" value="">
<input type="submit" name="choix" value="edit" formaction=".../edit/$_SESSION['id']">"
<input type="submit" name="choix" value="delete" formaction="......."
在控制器中:
public function editAction(){
$_SESSION['id'] = $this->_request->post('send')? $this->_request->post('send') : '';
(...)
}
当页面提交(发送)时,我有 SESSION['id'],但在 URL 中,我有“localhost/.../edit/”,这意味着 SESSION 值不会发送到 URL。如何同时发送值?感谢您的回答
解决方案
$_SESSION['id'] = $value
不是设置会话 ID 的正确方法,请使用
$value = $this->_request->post('send')? $this->_request->post('send') : '';
session_id($value);
session_start();
这应该使用您的新 ID 创建一个新会话,如https://www.php.net/manual/en/function.session-id.php中所述
推荐阅读
- asp.net - 如何在 Oracle 数据库中存储敏感数据(例如数据库密码)
- node.js - 如何保护用户从一个浏览器获取会话 cookie 并将其粘贴到另一个浏览器中进行登录?
- javascript - 在 JQuery 中禁用双击事件
- swift - 在视频应用程序中获取视频数据
- c# - Jquery FullCalendar 不适用于控制器上的 URL
- vuex - 为什么我们必须分离状态/突变/动作?
- wordpress - 有没有办法将 2 个域转发到 1 个 htaaccess 文件中的 HTTPS 地址?
- android - 如何创建“打字”风格的界面?
- r - 使用带有颜色的 geom_path 时的间隙
- html - 引导列在 chrome 中是正确的,但在 Internet Explorer 11 中不呈现。?