PHP GET变量直到会话运行

时间:2018-04-24 20:07:17

标签: php session session-variables

我将我的项目设计为此结构login.php (to login) -> index.php (to select year) -> dashboard.php (project started)。登录验证后,将启动索引页面以选择年份。此选定的年份ID将通过javascript传递到仪表板。

的index.php

<script type="text/javascript">
$('#year').change(function() {
    window.location.assign('dashboard.php?id=' + $(this).val());
});
    </script>

在仪表板中,我将此id指定为会话变量

dashboard.php

   $_SESSION['year_id'] = $_GET['id'];

在我使用的每个页面$_SESSION['year_id']。它工作正常。但问题从重新访问仪表板页面开始,因为$_GET['id']变为未定义的索引。并不是一次又一次选择年份的最佳方式。现在我想存储get变量直到会话运行。

0 个答案:

没有答案