dqmhgz5848 2018-12-06 07:45
浏览 47

在codeigniter中为会话变量添加新值

I am storing username and name in session

foreach($data as  $key=>$val)
                        {   
                            if($val->username == $username && $val->password == md5($password) )
                            {
                                $flag=true;
                                $newdata =array('name'=>$val->name,'username'=>$username);
                                $this->session->set_userdata($newdata);
                                break;
                            }

Now, a user uploads his profile picture, its path gets stored in database, and after that , i am getting that image from database.

public function get_image(){

            $this->load->model('UploadModel');
            $path= $this->UploadModel->get_path();

        } 

If i echo $path i got [{"img_path":"http://205.147.101.117/secureadmin/managment-panel/uploads/download_(1)2.jpg"}]

Now I want to store this path in my session variable , so that everytime i login the profile picture got displayed. Now i have 2 questions : 1) How to store this image path in already created session varible 2) Is there anyother way, to display profile picture..

Thank you, in advance

  • 写回答

3条回答 默认 最新

  • douhuang2282 2018-12-06 07:47
    关注

    You need to put session name into session function as like below

    $this->session->set_userdata('new_user_session_name', $newdata);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏