【问题标题】:php session between two pages两个页面之间的php会话
【发布时间】:2020-09-21 06:41:45
【问题描述】:

我的目标是当用户点击播放location_id时打开一个新会话(有一个用户会话的登录系统),然后他被重定向到下一页,他会从那里选择数据D b。 当print_r 会话我得到location_id 的空会话(用户会话很好!)

用户在这里选择一个点

$location_id = $_GET['location_id'];

echo $location_id;


        var i ; var confirmed = 0;
        for (i = 0; i < locations.length; i++) {
            marker = new google.maps.Marker({
                position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                map: map,
                icon :   locations[i][4] === '1' ?  red_icon  : purple_icon,
                html: "<div id='window_loc'>\n" +
                "<form method='POST' action='question.php'>\n" +
                "<table class=\"map1\">\n" +
                "<tr>\n" +
                "<td><input type='hidden'  id='manual_description'/>"+locations[i][3]+"</td></tr>\n" +
                "<tr>\n" +
                "<td><textarea disabled  id='question' placeholder='Question'>"+locations[i][5]+"</textarea></td></tr>\n" +
                "<tr>\n" +
                "<td><input type='hidden' name='location_id' id='location_id' value="+locations[i][0]+" /></td></tr>\n" +
                "<td><input id='button1' name='play' type='submit' value='play'/> </td></tr>\n" +
                "</table>\n" +
                "</form>\n" +
                "</div>"
            });


            google.maps.event.addListener(marker, 'click', (function(marker, i) {
                return function() {
                    infowindow = new google.maps.InfoWindow();
                    confirmed =  locations[i][4] === '1' ?  'checked'  :  0;
                    $("#confirmed").prop(confirmed,locations[i][4]);
                    $("#location_id").val(locations[i][0]);
                    $("#description").val(locations[i][3]);
                    $("#form").show();
                    infowindow.setContent(marker.html);
                    infowindow.open(map, marker);
                }
            })(marker, i));
        }




我已将此添加到用户被重定向但会话为空的页面(有一个 session_start 并且它有效 - print_r 显示用户 ID)

$location_id = $_GET['location_id'];

echo $location_id;

【问题讨论】:

    标签: php session


    【解决方案1】:

    也许这会有所帮助:

    • 您正在使用$location_id = $_GET['location_id'];(GET 方法),但在您的 JS 中您使用&lt;form method='POST'(POST 方法)创建了一个表单。

    $location_id 不是因为这个总是空的吗?也许这就是你的$_SESSION 没有任何变化的原因。

    您在哪里更新您的$_SESSION 数据? (代码中没有显示)。 你能把它改成:$_POST['location_id']然后重试吗?

    【讨论】:

    • 我已经更改了获取的操作并获得了 secsess tnx!
    猜你喜欢
    • 2019-08-10
    • 1970-01-01
    • 2019-04-04
    • 1970-01-01
    • 1970-01-01
    • 2012-08-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多