简体   繁体   English

将值从一个PHP会话传递到另一个

[英]Passing values from one PHP session to another

I'm working on an application with multiple roles, admin, faculty and student. 我正在处理具有多个角色(管理员,教职员工和学生)的应用程序。 Each of them have a unique view of the website according to their roles. 他们每个人都根据自己的角色拥有唯一的网站视图。 An admin's dashboard is different from a faculty member's dashboard, and accordingly, they are redirected to different pages after they log in. 管理员的仪表板与教师的仪表板不同,因此,登录后它们会重定向到其他页面。

Now, the admin can initiate certain actions, such as accepting applications. 现在,管理员可以启动某些操作,例如接受申请。 When the admin sends an email from his dashboard to students that they can now send the applications, I want that their dashboard be suitably modified ie., the extra option of sending an application is now visible. 当管理员从他的仪表板向学生发送电子邮件时,他们现在可以发送应用程序了,我希望他们的仪表板得到适当的修改,即,现在可以看到发送应用程序的其他选项。

So far, I had been dealing with $_SESSION variable for sending data across pages within the same session. 到目前为止,我一直在处理$_SESSION变量,以便在同一会话内的页面之间发送数据。 But now I want this information to be stored somewhere, so that when the student logs in, that extra option is visible. 但是现在我希望将此信息存储在某个位置,以便学生登录时可以看到该额外的选项。 What seems to be the best way to do this? 似乎最好的方法是什么? My application will have at least 2-3 such situations - accepting submissions, asking faculty members to make preferences etc, all depending upon the admin's decisions on when to initiate this. 我的申请将至少有2-3种这样的情况-接受提交,要求教职员工进行偏好设置等,所有这些都取决于管理员在何时启动此操作的决定。

You do not need to "pass values from one session to another". 您不需要“将值从一个会话传递到另一个会话”。

When the admin sends an email from his dashboard to students that they can now send the applications, I want that their dashboard be suitably modified 当管理员从他的仪表板向学生发送电子邮件以表明他们现在可以发送应用程序时,我希望对他们的仪表板进行适当的修改

You simply need to change some state in your application, ie the database. 您只需要在应用程序(即数据库)中更改某些状态。

After the dashboard has read that state, it comes down to a simple test: 仪表板读取该状态后,可以进行以下简单测试:

if (!$user_already_applied) {
    if ($applications_open) {
        // display application form
    }
    else {

    }
}
else {
   // whatever you want to happen...
}

$ _SESSION是一个超全局变量,每个用户只能访问一个会话实例,您必须创建一个基于角色的系统,对于每个角色,您都可以提及每个用户使用自己的帐户时可以访问的功能类型那么只有该功能/页面可供他们使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM