FMATeam Posted October 5, 2008 Share Posted October 5, 2008 I'm trying to store some array keys in a cookie $USERS["user1"] = "random MD5 hash"; $USERS["user2"] = "another random MD5 hash"; $USERS["user3"] = "another random MD5 hash"; this is basically a login system and i'm trying to display the username used by any user when they login. I'm trying to store the key in the cookie. Then recall it and print it using another file so it'll say "Welcome user1" or whatever. Can anyone help...cheers Link to comment https://forums.phpfreaks.com/topic/127157-store-array-in-cookie/ Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 Use serialize() and unserialize() on the array when you store it and retrieve it, respectively. Link to comment https://forums.phpfreaks.com/topic/127157-store-array-in-cookie/#findComment-657772 Share on other sites More sharing options...
FMATeam Posted October 5, 2008 Author Share Posted October 5, 2008 I had a look on php.net and I don't understand how I would go about using it. Link to comment https://forums.phpfreaks.com/topic/127157-store-array-in-cookie/#findComment-657775 Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 Sorry, I was playing Mario Kart and typed the wrong thing. I meant: setcookie('users', serialize($USERS)); Link to comment https://forums.phpfreaks.com/topic/127157-store-array-in-cookie/#findComment-657777 Share on other sites More sharing options...
Barand Posted October 5, 2008 Share Posted October 5, 2008 Why do you want to store User2's info on User1's and User3's PC, and so on? Link to comment https://forums.phpfreaks.com/topic/127157-store-array-in-cookie/#findComment-657820 Share on other sites More sharing options...
FMATeam Posted October 6, 2008 Author Share Posted October 6, 2008 Thanks DarkWater Why do you want to store User2's info on User1's and User3's PC, and so on? I'm not. What I'm trying to do is store the users username in a cookie and recall it and print it when they've logged in. E.g. when user1 logs in I want the homepage to say, "Welcome user1" and when user2 logs in, the homepage will say "Welcome user2" Link to comment https://forums.phpfreaks.com/topic/127157-store-array-in-cookie/#findComment-657983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.