Getting the customer id if session is not set - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Getting the customer id if session is not set (/showthread.php?tid=65820) |
Getting the customer id if session is not set - wolfgang1983 - 07-27-2016 Hi, sorry for lots questions on auto logins I am just new at that. I am creating a auto login for my front end system. When the session has expired it unset the customer id. I use my readAutologin function to see if any rows return with customer id. But because it does not exist in the session or cookie I do not no the better way of being able to get customer id for my readAutologin My cookie data only has tokens it has no customer id's PHP Code: public function readAutologin() { I was thinking instead of PHP Code: public function readAutologin() { What is your suggestion? There is no encryption at the moment I am just playing around to it working? Full Code Here RE: Getting the customer id if session is not set - InsiteFX - 07-28-2016 You can add this to your class: PHP Code: // Add this as a class variable RE: Getting the customer id if session is not set - wolfgang1983 - 07-28-2016 (07-28-2016, 04:19 AM)InsiteFX Wrote: You can add this to your class: Do I put the bottom 2 in the __construct() area? RE: Getting the customer id if session is not set - InsiteFX - 07-28-2016 (07-28-2016, 04:27 AM)wolfgang1983 Wrote:(07-28-2016, 04:19 AM)InsiteFX Wrote: You can add this to your class: You first need to get your customers id, I would create two new methods setCustomerId() and getCustomerId() I see you are getting the customers id in the postLogin method so that would be were you would set it. You get the customer id anywhere you need it after that. Also if you do not need the customers id outside of this class then make the variable private. RE: Getting the customer id if session is not set - wolfgang1983 - 07-28-2016 (07-28-2016, 04:30 AM)InsiteFX Wrote:(07-28-2016, 04:27 AM)wolfgang1983 Wrote:(07-28-2016, 04:19 AM)InsiteFX Wrote: You can add this to your class: Did not work returning 0 RE: Getting the customer id if session is not set - InsiteFX - 07-28-2016 Sorry try this PHP Code: static protected $customerId = 0; By all means it should be working are you sure that you are returning the customer id? RE: Getting the customer id if session is not set - wolfgang1983 - 07-29-2016 (07-28-2016, 05:55 AM)InsiteFX Wrote: Sorry try this I gave it another go still not work was all way returning 0 Here is what I have done so far. The only thing that is stopping me is I cannot get the customer id for readAutologin because session expired. I have all ways been told not to hide customer id or user id in cookies only tokens. So I can not think of any other way to get id. RE: Getting the customer id if session is not set - InsiteFX - 07-29-2016 I'll work something up for you and get back to you later on, using the tokens and database. RE: Getting the customer id if session is not set - wolfgang1983 - 07-29-2016 (07-29-2016, 04:26 AM)InsiteFX Wrote: I'll work something up for you and get back to you later on, using the tokens and database. I have worked it out with tokens my self have now got the idea about serialize the tokens in the cookie into array and then encode them then decode them into read part then verify the token that is set in customer with the token that is set in customer autologin and have a key token for extra security. that would change every so often. It has been stuffing up my head but now think got it. RE: Getting the customer id if session is not set - InsiteFX - 07-29-2016 All you need to do is save the customer_id to the user_id in the auth_tokens table You already have the token for that user. |