Welcome Guest, Not a member yet? Register   Sign In
Flashdata Destroying Session
#1

[eluser]Unknown[/eluser]
I've been using flash data a lot recently with no problems but I've come up against something that is driving me crazy.

What I want do do is set some flash data which is the result of a DB query.

Here is the controller:

Code:
//get the name based on the ID
$unitname = $this->game_model->getUnitName($_POST['type']);
//make a description to put into flashdata
$desc = 'You bought ' . $_POST['num'] .' '. $unitname;
                            
//set the flashdata
$this->session->set_flashdata('info', $desc);
//go back to where we started
redirect ("game/bleh");

and here is the model:

Code:
function getUnitName($unitID)
{
    if (empty($unitID)){return false;}
    
    $query = $this->db->query(' SELECT unitName FROM units WHERE unitID = "'. $unitID .'"');
    $result = $query->row();
    return $result->unitName;    
}

When it hits set_flashdata is just destroys the session and redirects me back to my login page. I tried just echoing the $desc and it works perfectly with that, I also tried just using the $_POST variables and that worked too. It just breaks when I try and use the result of a query in the description. I searched the forum quite a bit and the only similar problem I could find was someone that was inserting too much data into the flashdata. In my case it's only a very short string (one short sentence) so this cannot be the case.

Am I just a complete idiot (very possible) and doing something stupid here?

Thanks
#2

[eluser]TheFuzzy0ne[/eluser]
I've known long strings, and characters such as backslashes to cause cookies to break. I'd suggest testing it with some fake data, to see if it still breaks.

You may also want to try storing session data in your database instead.
#3

[eluser]The Wizard[/eluser]
there are issues with this i encountered too, however i do not remember how i did a workaround but i definitely did one.




Theme © iAndrew 2016 - Forum software by © MyBB