cookie login help |
[eluser]UnknownPlayer[/eluser]
There is my controller: Code: function login() { My login page view form: Code: <?php And my check_login() function: Code: function check_login() { And 2 tables. ci_session: and ci_cookies: And still error Code: An Error Was Encountered When i remove: Code: if ($this->rememberme->verifyCookie()) {
[eluser]besson3c[/eluser]
Ahhh.. check out your RememberMe Spark config: https://github.com/joeauty/RememberMe-Co...mberme.php Set this to your liking. Remove the requiremodel and authfunc variable settings if you don't wish to use the supported callbacks provided by the Spark and instead wish to write your own authorization checks. These are simply intended to verify that the user exists and should have access, but it looks like you have already done that with your User_model.
[eluser]UnknownPlayer[/eluser]
One more error fixed, but another is there Code: A Database Error Occurred There is error $user_id = $this->session->userdata('user_id'); Can't retrive that session value What is next move ? I don't know if this is error, but in db on field netId is "Remember me" text, is that right or no ?
[eluser]besson3c[/eluser]
Getting the user id by calling on $this->session->userdata('user_id') is not going to be 100% reliable, because this is only set when you login, and only for that session. You need a: Code: if ($this->rememberme->verifyCookie() && !$this->session->userdata('user_id')) { somewhere near the top of your code (e.g. your core controller) to handle accessing the site with an expired CodeIgniter session if you wish to use your user_id session variable this way. If this is not the cause of your problem, I'd suggest testing to see if there is a problem with retrieving session variables in general, outside of the context of the RememberMe spark. Are you saying that the value of the netId field in ci_cookies is literally "Remember me"? This would be causing the problem if so, it should store your user id and be the exact same as what you'd expect $this->session->userdata('user_id') to be.
[eluser]UnknownPlayer[/eluser]
I think that error is on that Remember me field in db, becouse i setCookie like this: Code: if ($user->user_id) { Look at this comments, see if there is error? Can i send you project(there are only user controller, model and view), and sql, so you can fix it, and tell me errors, to know for later, or maybe to join using teamviewer to check ?
[eluser]InsiteFX[/eluser]
One thing to keep in mind is that radio buttons and checkboxes will not return any value if they are not checked! If you try to read a checkbox that is not checked you will get an error because the value is undefined. For remember me I create a hash key using sha512 and save it in the users database record and write it out to the cookie thats all! If the user has a remember me cookie I read in the hash value from the cookie and get the users record based on the hash code value, then I automatically log the user in.
[eluser]UnknownPlayer[/eluser]
I made it works, thanks for help guys. Mistake was on start of login controller, i set to secCookie, but not only when validation is run.. Thanks guys. But do i need to use authfunc, or i can just use: Code: function check_login() {
[eluser]besson3c[/eluser]
authfunc just allows you to plug in your own authorization checks to not only check to see if the user has their login cookie set, but whether they should have access to the application or page being viewed. This is actually important because if there is a valid cookie set and the user hasn't paid for subscription to your app or is no longer an employee or something, they shouldn't have perpetual access to the application. If you don't need to do any particular authorization checks, what you have will work fine!
[eluser]besson3c[/eluser]
Glad you got it working! If you are willing/able, I'd love to see your code in action if there is a URL you could point me at... |
Welcome Guest, Not a member yet? Register Sign In |