Hello how can I pass a different $_SESSION variable depending on which link I clicked? For example something like this.
<a href="page2.php value="<?php echo $_SESSION['variable'] = "Foo" ?>Foo</a>
<a href="page2.php value="<?php echo $_SESSION['variable'] = "Bar" ?>Bar</a>
And in page2.php receive the correct value. How can I do this without using $_POST or $_GET? Thanks in advance!
答案 0 :(得分:0)
只有这种方式(但你需要将变量发送到服务器,因为SESSION你只在服务器端):
<a href="page2.php?page=foo">Foo</a>
<a href="page2.php?page=bar">Bar</a>
使page2.php
<?php
if ($_GET['page'] == 'foo') {
$_SESSION['variable'] = "Foo";
} elseif ($_GET['page'] == 'bar') {
$_SESSION['variable'] = "Bar";
}