首页 > 解决方案 > 我有一些网址,当点击网址时,我们应该知道谁点击了,哪个网址,用户点击了codeigniter

问题描述

我有一些指向 PDF 的 href 链接,当用户使用用户名和密码登录并点击特定的 href 链接时,我想知道哪个用户点击并访问了哪个链接。

标签: phpmysqlcodeigniter

解决方案


您是否在登录后将用户详细信息存储在会话中,如果您已将用户数据存储在会话中,则它必须是直截了当的任务。

在您的控制器中

 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

推荐阅读