如何获得会话的价值

时间:2017-07-28 07:40:39

标签: php session cookies session-variables session-cookies

如何从home.php获取值并使用SESSION将其传递给1home.php。我希望1home.php获取home.php的值,每次我改变它的值。

session_start();
<form method="post" action="1home.php">
    <label id="checkinD">
            <h3>Day</h3>
                <Input id="chiD" name="chiD" type="number" min="<?php echo $_SESSION["day_today"]; ?>" max="<?php echo $_SESSION["day_count"]; ?>" required />
            </label>
</form>
session_start();
<form method="post"  action="2home.php" onsubmit="return validate()">
<label id="checkinD">
                    <h3>Day</h3>
                        <Input id="chiD" name="chiD" type="text" value = " 
<?php echo $chiD; ?>"  readonly />
            </label>

1 个答案:

答案 0 :(得分:1)

在第一页中你有值

session_start();


$_SESSION["yourValue1"] = $yourValue1;
$_SESSION["yourValue2"] = $yourValue2;

在第二页中你想要得到它们

session_start();

echo "your yourValue1 value is " . $_SESSION["yourValue1"] . ".<br>";
echo "your yourValue2 value is " . $_SESSION["yourValue2"] . ".";