Welcome Guest, Not a member yet? Register   Sign In
db_session and set_flashdata problem
#1

[eluser]Unknown[/eluser]
Hello,
I'm having problems displaying session flashes.

This is what I have:

Code:
function index()
{
    $data['msg'] = $this->db_session->flashdata('msg');
    $this->layout->view('my_view', $data);
}
function add()
{
    $this->db_session->set_flashdata('msg', 'Item added!');
    redirect('thiscontoller');
}


I'm using FreakAuth for authentication and when I use above code, it clears the sessions and logs me out by displaying the login page. Any ideas?
#2

[eluser]Unknown[/eluser]
I'm having the same issue. Anybody got this fixed?
#3

[eluser]cwpollock[/eluser]
I to am having this issue. I'm eager to hear a response.
#4

[eluser]Derek Allard[/eluser]
What is the issue all? Could you explain it outside the scope of freakauth?
#5

[eluser]pioSko[/eluser]
Ok, I'm having the same problem... and i may have an idea as to why it's happening. However, my n00b knowledge on sessions and ci in general means I may be wrong Tongue

I've got a db_sessions and Lang Selection setup (http://codeigniter.com/wiki/Language_Selection/)

First a question: Should db_session be creating a new session_id everytime i open a page... ANY page.. on my site?? I've checked my database table and it just keeps creating new entries everytime I change a menu item (for example)

Anyways, with that in mind, changing the language invokes a function which writes to the db and then redirects using flashdata (uri stored in flash) ... but it does not redirect to the previous page because a NEW sescsion is being created and therefore the previous flashdata is now in a useless previous database entry not being used.

does what i've written make sense??
#6

[eluser]adamp1[/eluser]
I found I had this problem a while ago. It was with FreakAuth I had the issue with. In the end I couldn't find a solution. For what ever reason FreakAuth didn't like me touching its sessions.

Its not a problem with CI since the session library in FreakAuth is not the offical CI one.

I don't use FreakAuth (use my own) and I use the offical CI sessions library and it works fine. Personally I think its a problem with FA but couldn't be bothered to find a fix.
#7

[eluser]cwpollock[/eluser]
I'm glad some conversation is generating here, I'll try to be more detailed in the problem I'm having and what I've noticed.

Environment:
I'm running PHP 5, mySql 5, Apache 2 on Windows using WAMP

CodeIgniter 1.6.1 using the Auth plugin

Presenting Problem:
After a I login the authentication does not stay in the session. I have intersted "break;" statements at various points in the code and can see that authentication IS successful, but that it doesn't store it then in Session.

Debugging:
What I see is that this value appears in the session table immediately after I login:

a:1:{s:23:"flash:oldConfusedentry_status";b:0;}

If I navigate to another page the session appears as:

a:0:{}

Essentially it looks like (as the first user described) that somehow the values in session_data field are being overwritten instead of concatenated together.

Hope this helps someone point out the problem.
I haven't changed either module.

If someone can recommend a better authroization module I'd would even tolerate trying another.

Thanks!
#8

[eluser]adamp1[/eluser]
I would love to say try mine, but haven't finished it yet. Personally I think it will knock the pants off most others since it has Access Control Lists. Iv been putting a lot of work into making how you manage them as easy as possible.

Just need to polish off a few bits, before release.
#9

[eluser]pioSko[/eluser]
I'd love to get my hands on an easy to install and implement authorization kit. The ones I've tried from the wiki are a pain inthe @rse. Freak didn't even work for me and I ha no clue as to why since it's install doc was so vague.
#10

[eluser]cwpollock[/eluser]
Ok.. here's some more data. I stuck some debugging into my code

Here's what I put in:
Code:
function sess_update()
    {        
        $this->userdata['last_activity'] = $this->now;
        // format query array to update database
        $ud = $this->userdata;
        $query_array = array(     'last_activity' => $ud['last_activity'],
                    'user_agent'    => $ud['user_agent'],
                    'ip_address'    => $ud['ip_address'] );
        unset($ud['session_id']);
        unset($ud['last_activity']);
        unset($ud['user_agent']);
        unset($ud['ip_address']);
        $query_array['session_data'] = serialize($ud);
        
        print_r($query_array);
        //break;
        echo "<p>" . $this->object->db->update_string($this->session_table, $query_array, array('session_id' => $this->userdata['session_id'])) . "</p>";
        
        $query = $this->object->db->query($this->object->db->update_string($this->session_table, $query_array, array('session_id' => $this->userdata['session_id'])));
        
        echo "<p>Result: " . $query . "<p>";
        
        // Write the cookie
        $this->sess_send_cookie();
    }
    // END sess_update()

Here's what I got
Code:
Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:1:{s:7:"user_id";s:1:"3";} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:1:{s:7:\"user_id\";s:1:\"3\";}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:2:{s:7:"user_id";s:1:"3";s:9:"user_name";s:9:"cwpollock";} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:2:{s:7:\"user_id\";s:1:\"3\";s:9:\"user_name\";s:9:\"cwpollock\";}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:3:{s:7:"user_id";s:1:"3";s:9:"user_name";s:9:"cwpollock";s:5:"users";a:1:{i:3;s:9:"cwpollock";}} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:3:{s:7:\"user_id\";s:1:\"3\";s:9:\"user_name\";s:9:\"cwpollock\";s:5:\"users\";a:1:{i:3;s:9:\"cwpollock\";}}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:2:{s:9:"user_name";s:9:"cwpollock";s:5:"users";a:1:{i:3;s:9:"cwpollock";}} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:2:{s:9:\"user_name\";s:9:\"cwpollock\";s:5:\"users\";a:1:{i:3;s:9:\"cwpollock\";}}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:2:{s:9:"user_name";s:9:"cwpollock";s:5:"users";a:1:{i:3;s:9:"cwpollock";}} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:2:{s:9:\"user_name\";s:9:\"cwpollock\";s:5:\"users\";a:1:{i:3;s:9:\"cwpollock\";}}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:2:{s:9:"user_name";s:9:"cwpollock";s:5:"users";a:1:{i:3;s:9:"cwpollock";}} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:2:{s:9:\"user_name\";s:9:\"cwpollock\";s:5:\"users\";a:1:{i:3;s:9:\"cwpollock\";}}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:1:{s:5:"users";a:1:{i:3;s:9:"cwpollock";}} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:1:{s:5:\"users\";a:1:{i:3;s:9:\"cwpollock\";}}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

Array ( [last_activity] => 1204775796 [user_agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv [ip_address] => 127.0.0.1 [session_data] => a:0:{} )

UPDATE ci_sessions SET last_activity = 1204775796, user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv', ip_address = '127.0.0.1', session_data = 'a:0:{}' WHERE session_id = '4795bda6d636de05800e9b341c0b5d1e'

Result: 1

This is calling the simple "login()" option from the Auth module. Notice the last entry. That's what's killing my login. I've tried to trace where that would be coming from in the code, but I can't find where that is happening.




Theme © iAndrew 2016 - Forum software by © MyBB