Jump to content

retrieve the cookie?


flix_is_here22
 Share

Recommended Posts

hi, i so confused with retrieve the cookie when retrieve the cookie in the other file....i have some file....1. login.php -----> this file have a action form to checklogin.php2. checklogin.php -->cookie usrname to be set and the end of code i put header("location: home.php")3. home.php ---> menu of my website after user login. so i really confused when i retrieve the cookie usrname in the file home.php.....how to retrieve the cookie of usrname into home.php....??i has been try this code :echo $_POST["usrname"]; orecho $_COOKIE["usrname"];but both of this code isn't work..... :fool:any sugesstion??

Link to comment
Share on other sites

Guest LH91325

It is $_COOKIE["usrname"] where "usrname" is the name of your cookie. It needs single or double quotes around the name because that is the array index. Use your browser to verify that your set cookie code actually worked. Like Firefox -> Tools -> Options -> Privacy -> Show Cookies. If it is not there then look at your set cookie code. If it is there and the name is correct then look at your check cookie code. When you get that working it's more sophisticated to have your login.php action back to itself. Then it can verify correct cookie and die(header('Location: /home.php')); Or if there's an error (wrong password) it can repeat the login form and fill the username field to make it easier to try again.

Edited by LH91325
Link to comment
Share on other sites

hahaha... :rofl:thx both of you for reply.... i really hopeless yesterday so i get some idea. i change process to get cookie using creating file and put the cookie in the their file.....so i can show the cookie everytime i want..... :rofl:honestly i bit cheating about retrive the cookie.... :rolleyes:

Edited by flix_is_here22
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...