Welcome Guest, Not a member yet? Register   Sign In
Cookie encryption question (newbie question)
#1

[eluser]faluci[/eluser]
I'm on 'localhost' Xampp.

I have this question when thinking of building a Remember Me log-in feature.

Basic idea is to store user_id, token (spot of granting remember me to check if the token is the same as in the database) in cookie. (not in session 'cos I want to allow remember me from multiple devices e.g. mobile phones, PCs etc)

Thought it's better to store these data encrypted in cookies.

So using
Code:
$config['encryption_key'] = 'some_key';
with
Code:
set_cookie($this->encrypt->encode());
Code:
$this->encrypt->decode(get_cookie());
to store data in cookies would be a way.

Question 1. Is there a auto-encode & decode feature (e.g. cookie helpers?) like above without using
Code:
$this->encrypt->encode();

I doubt there is a feature I described somewhere between
Code:
$config['sess_encrypt_cookie'] = TRUE;
(Maybe not... I guess this is for session_cookie only)
Code:
$config['cookie_secure'] = FALSE;
(I dont have https enabled in my localhost, so I couldn't test with this)

Question 2. maybe this is 'localhost' issue but when I set cookie using
Code:
$this->input->set_cookie($str);
I can see values in file
Quote:Cookie:admin@localhost/
However, (using PHP function)
Code:
$value = "not really dude";
setcookie("TestCookie", $value);
I cant see this value in the file. But
Code:
print_r ($_COOKIE);

returns
Code:
array ([TestCookie] => not really dude)
Why is this? (no other cookie files written so where the hell is this information stored?)
#2

[eluser]InsiteFX[/eluser]
I just store a hash key in the cookie and check it in the users record for a match!




Theme © iAndrew 2016 - Forum software by © MyBB