【发布时间】:2021-05-14 06:57:40
【问题描述】:
functions.php
<?php
if ( !defined('ABSPATH') ){ die(); }
ob_start();
if (!session_id()) {
session_start();
}
plugins/bestellung/bestellung.php
<?php
add_shortcode('disp_bestellung_sidebar', 'display_side');
function display_side() {
if($_SESSION["ptitle"] != "") {
echo '<h3 class="bestellung_sidebar_title">Product</h3>';
return ob_get_clean();
}
}
plugins/bestellung/bridge.php
if (isset($_POST['prtitle'])) {
$_SESSION["ptitle"] = $_POST['prtitle'];
}
header( 'Location: /bestellung/' );
在bridge.php 中,我可以获得 $_SESSION["ptitle"] 及其值。
但是在它重定向到另一个页面之后,即“/bestellung/”,在此之前已经设置了其他键/值。
为什么会话中的值变成了别的东西?
【问题讨论】:
标签: php wordpress session plugins shortcode