php - 我有一些网址,当点击网址时,我们应该知道谁点击了,哪个网址,用户点击了codeigniter
问题描述
我有一些指向 PDF 的 href 链接,当用户使用用户名和密码登录并点击特定的 href 链接时,我想知道哪个用户点击并访问了哪个链接。
解决方案
您是否在登录后将用户详细信息存储在会话中,如果您已将用户数据存储在会话中,则它必须是直截了当的任务。
在您的控制器中
public function pdfview() {
$user_id= retrieve from session //get from session
$this->body['user_id'] = $user_id // for passing data in view
$this->load->view('your_view',$this->body); //passing user_id to view
}
public function viewpdf(){
$url=$this->uri->segement()//url
$user_id=$this->input->get(user_id);
//now you can know which user has accessed which link
//you can store it or do as u please
}
在您看来“Your_view.php”
<a href="<?php echo base_url()?>your_controller/viewpdf?user_id=<?php echo $user_id?></a> // link to pdf for users and you can send other attributes accordingly to satisfy your need
推荐阅读
- powershell - PowerShell 事件查看器错误
- python - 如何更新脑切片的 Tkinter 图中的值,以便能够从 4D 图像中翻阅不同的脑容量
- angular - Rxjs zip 与 rest 调用两次调用
- excel - VBA根据表的数据列表锁定/解锁每一行
- javascript - 在 React 中切换语言而不使用外部库
- jsf - 为什么 UTF8 字符编码在 JSF 中不起作用?
- core - MS chart 将图表缩放到一个区域
- python - 如何将看起来像列表的 str 转换为没有库 ast 的列表
- trello - 如何使用 Trello API 获取板、列表和卡片的上次更新时间戳?
- flutter - 找不到正确的提供者 - Flutter