Page 1 of 1

Cookie question - more information in one cookie

Posted: Wed Jul 08, 2009 8:26 am
by JKM
Isn't it possible to save more information that one line in a cookie?
line1: name
line2: pw
line3: some security check

And have it like this:
$_COOKIE['mypage_cookie']['name']
$_COOKIE['mypage_cookie']['pass']
$_COOKIE['mypage_cookie']['hash']

If so, how do I solve it? Thanks.

Re: Cookie question - more information in one cookie

Posted: Wed Jul 08, 2009 6:00 pm
by Peter Anselmo
All cookies are simply key/value pairs. You would need to create a separate cookie for each value.

Does your user have separate logins for different pages on your site? If not, why not just change this:

Code: Select all

$_COOKIE['mypage_cookie']['name']
$_COOKIE['mypage_cookie']['pass']
$_COOKIE['mypage_cookie']['hash']
to this:

Code: Select all

$_COOKIE['name']
$_COOKIE['pass']
$_COOKIE['hash']

Re: Cookie question - more information in one cookie

Posted: Thu Jul 09, 2009 12:45 pm
by Darhazer
Alternatively, you can serialize array to set it as a cookie's value, and unserialize it when you read it.