Welcome Guest, Not a member yet? Register   Sign In
User Authentication - Placement of code?

That's partly why I used this line in my 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).

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:
The session is destroyed and the user is shown the home page once the session is destroyed. The link that I have is this:
// 'login' is the class (it's also the file name) and logout is the function as per the user guide
anchor('login/logout', 'Logout');
However this is not working. Perhaps I just don't understand how CI handles URL's.

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!

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

Thanks, I'll take a look at that and see what I can do. Did you have any advice for the links?

Did you echo the link?
echo anchor('login/logout', 'Logout');

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.

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?

Does anybody have any advice? Thanks.

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.


Simply don't load sessions for the controllers where no login or use of session data is needed.

Theme © iAndrew 2016 - Forum software by © MyBB