• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sessions WTF

#1
[eluser]Phil Sturgeon[/eluser]
Got a real odd one here. If im just being an idiot then make your jokes and get it over and done with, at least its fixed.

Code:
function report($videoID)
    {
    
        $this->load->library('session');
        $this->load->library('user_agent');
        $this->session->set_userdata('reported_'.$videoID, true);
        // If there isnt a session saying this game is already voted on
        if($this->session->userdata('reported_'.$videoID) !== true and !$this->agent->is_robot()):
        
            $this->load->model('video_model');
            
            // Then set their new vote
            if($this->video_model->report($videoID)):
                $this->session->set_userdata('reported_'.$videoID, true);    
            
                $this->data['message'] = 'This game has been reported. A moderator has been notified and action should be taken very soon.';
            else:
                $this->data['message'] = 'This game could not be reported for some reason. Please try again at a later time.';
            endif;
        else:
            $this->data['message'] = 'Sorry, you have already reported this video. A moderator has been notified, reporting a second time will have no effect.';
        
        endif;
        
        echo 'test:'.$this->session->set_userdata('reported_'.$videoID);    
        
        $this->template->title("Videos > Video Reported");
        $this->template->create("videos/message", $this->data);
    
    }

For SOME reason its not setting the session... why? I get the message:

Quote:This game has been reported. A moderator has been notified and action should be taken very soon.

every damn time and it always reports it!

#2
[eluser]chobo[/eluser]
I would just check what this line returns and go from there. It seems your query(?) always returns true.

Code:
if($this->video_model->report($videoID)):

Just a quick update, I noticed you have this line.

Code:
echo 'test:'.$this->session->set_userdata('reported_'.$videoID);

I don't use codeigniters session library, but I think you need to use this to retrieve session data

Code:
echo 'test:'.$this->session->userdata('reported_'.$videoID);

#3
[eluser]Phil Sturgeon[/eluser]
As I said its obviously returning correctly as the message is:

Quote:This game has been reported. A moderator has been notified and action should be taken very soon.

which comes directly after the session setting.

Problem seems to have gone away now thankfully, have no idea what was causing it. Have used sessions plenty of times but this was just a really really odd one!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.