Welcome Guest, Not a member yet? Register   Sign In
Session Destory not Destorying
#1

[eluser]adamp1[/eluser]
I'm in the process of writing a Auth system, login works fine and uses db_session to store login data. Now for logout I use $this->db_session->sess_destroy() but it doesn't do anything. The cookie is not changed OR removed.

I have also tried using unset_userdata(..) but that too doesn't change the cookie OR session stored in DB.

Has anyone else tried this and got the same result.

I have tried in both FF 1.5 and IE7, same problem.

The only thing I can think of is to add extra code to sess_destory to delete the row in the database corresponding to the session_id
#2

[eluser]krsanky[/eluser]
I am also using DB_Session for auth.
My cookies DO get deleted. The data in the DB does not.
I was thinking of modifying sess_destroy() to delete the relevant row from the DB.
Logically I think that is the correct behavior. I have a feeling that the author might not have implemented that, because its not really necesary as long as the cookie is deleted. GC will eventually delete the row.

I still might update sess_destroy to remove the db table, because then I can query the db to see what active sessions I have.
#3

[eluser]krsanky[/eluser]
I added this to DB_Session.php's sess_destroy() method:
It deletes the session's row from the table.
It seems to work fine so far.
Code:
//and delete the row from the db
        $session_id = $this->object->input->cookie($this->sess_cookie);
        if( isset( $session_id )){
            $this->object->db->where('session_id', $session_id);
            $this->object->db->delete($this->session_table);
        }


PS. On a side note; I renamed DB_Session.php to Session.php, and renamed
the class CI_Session.

This makes it a drop-in replacement for CI's Session code.
(Ie. dont have to change the $this->session... calls to $this->db_session...)
#4

[eluser]mrbinky3000[/eluser]
FACT: CodeIgniter's Session Class is NOT RELIABLE.

CI's session class uses cookies. The cookies they write are standards-compliant, but don't work with IE. So, the problem is with CI's refusal to work around IE's non-standards-compliant handling of cookies. Meanwhile, the rest of us have to suffer because of CI's refusal to get off their high-horse and make something that works in the REAL WORLD.

Check out this thread for a working solution.
http://ellislab.com/forums/viewthread/130577/#669025

Also in the wiki.
http://codeigniter.com/wiki/Dariusz_Debo...ion_Class/

Please contribute to Dariusz Debowczyk's Session Class. My hope is that enough of us can get together and make a session class that works.
#5

[eluser]CI_avatar[/eluser]
@adamp1 using $this->db_session->sess_destroy() is correct. all you have to is to redirect the file.

heres the diagram:

1. main.php -> redirects to -> session_destroy.php ('which contain the code $this->db_session->sess_destroy()')
2. (after destroying the session) session_destroy.php -> redirects to -> main.php
#6

[eluser]skunkbad[/eluser]
[quote author="mrbinky3000" date="1258669126"]... Meanwhile, the rest of us have to suffer because of CI's refusal to get off their high-horse and make something that works in the REAL WORLD.[/quote]

Ya know, I don't use CI sessions a lot because I don't like them, but EllisLab has given you a wonderful free software product, and you should show some respect. The beauty of CI is that it is very flexible, and you can always revert to the php that it rides on. Nobody is holding a gun to your head, demanding that you use CI sessions. If the CI session library was completely removed, it would still be an awesome framework, and I would still be using it. You can extend or replace it, so why be hostile?
#7

[eluser]stuffradio[/eluser]
Why are you replying to a thread that's two years old!?




Theme © iAndrew 2016 - Forum software by © MyBB