duanmingting9544 2010-09-27 09:46
浏览 49
已采纳

Php会话变量bug

There is a problem with session variables in my web-application. I have several types of documents, when user want to edit it, he pushes a button and php record number of document to $_SESSION['patent_number'] via GET method. All fine when launch application. I test it with 2 documents with 2 different numbers. In the begining all works fine, but then it seems that session variable is not changed and i see document with another number.

When user click "Edit" button, he sends a document number to patent_load.php, and it's always correct loading:

var patent_number=$(this).val();
$('#user_input_text').load('pages/patent/patent_load.php?section=patent_claims&patent_number='+patent_number);

But when i click to the section of document from menu, there appears old session number:

$('#user_input_text').load('pages/patent/patent_load.php?section=patent_claims');

Here is a patent_load.php:

session_start();
session_regenerate_id();

if (isset($_SESSION['id'])){

    $db=new mysqli('X','X','X','X');    
    $db->set_charset("utf8");

    $section=$_GET['section'];
    if(isset($_GET['patent_number'])){
        $number=$_GET['patent_number'];
        $_SESSION['patent_number']=$number;
        echo 'get is set';
    }
    $patent_number=$_SESSION['patent_number'];

        $query="select $section from new_patent_document where patent_number='$patent_number'";
        $result=$db->query($query);
        $row=$result->fetch_assoc();
        echo $patent_number.', ';
        echo $row[$section];

Any ideas how can i solve it and why session variable isn't updated. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • duanli6834 2010-09-27 11:10
    关注

    Check if the browser caches the requests you make via GET. I don't know how your app is designed, but if you use the "back" button from the browser(or via javascript) you will encounter this situation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大