User Authentication - Placement of code? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: User Authentication - Placement of code? (/showthread.php?tid=5420) |
User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]ekeretex[/eluser] That's partly why I used this line in my code Code: $this->data['session_id'] = $this->session->userdata('session_id'); If you use the full string in the conditional it fails ( I have no idea why but I've learnt to work around it). User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]RyanH[/eluser] That makes sense. I'm attempting to test this but for whatever reason, I can't get a few things to work before I can test this. The first being I can't get the logout link to work. I've read the user guide for URL's and I thought it made sense, but it's apparently not working. I created a logout function in the login controller file that does the following: Code: $this->session->sess_destroy(); Code: // 'login' is the class (it's also the file name) and logout is the function as per the user guide Secondly, it seems as if each page I go to while I'm "logged in", a new session is created. Any particular reason? Anyway to fix this? Thank you for your help! User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]ekeretex[/eluser] After destroying the session, it's best to redirect to a new page rather than load a view because the session is not killed on the page you call the session_destroy. I have had a lot of issues with the CI session library in the past and have given up on it. I currently use OBSession User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]RyanH[/eluser] Thanks, I'll take a look at that and see what I can do. Did you have any advice for the links? User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]ekeretex[/eluser] Did you echo the link? Code: echo anchor('login/logout', 'Logout'); User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]RyanH[/eluser] Yes. The link is there, but it doesn't do anything. Is my link correct? login being the class name and logout being the function within that class. User Authentication - Placement of code? - El Forum - 01-21-2008 [eluser]RyanH[/eluser] I just noticed another problem that I seem to be having. It appears that a session is being created every time a person visits the site. I only want sessions to be created when someone logs in, and then destroyed when the person logs out. Secondly, I tried the OBSession library and nothing was being stored in the database. I updated the database table, the config file and over wrote the Session.php in the library folder. Anything I'm missing? User Authentication - Placement of code? - El Forum - 01-23-2008 [eluser]RyanH[/eluser] Does anybody have any advice? Thanks. User Authentication - Placement of code? - El Forum - 01-23-2008 [eluser]Kemik[/eluser] The CI session library creates a session for everyone. There's no way around this. You could add a line to the session (such as user_id) when the user logs in then check for that data when checking if the user is logged in. User Authentication - Placement of code? - El Forum - 01-25-2008 [eluser]Crimp[/eluser] RyanH: Simply don't load sessions for the controllers where no login or use of session data is needed. |