okay, im trying to make a script to login on a site, then click some links on the site and fill some forms. but after the login, it lose the cookie, says cookie not found
One problem could be that your cookies are written to www.yoursite.com and you are at yoursite.com (Or reverse). I had this problem the other day.
Also make sure you send your setcookie() command before ANY output is sent, as it will generate errors and fail to set cookies. Make sure you are calling your cookie variables via the $_COOKIE array.
Not to mention that you shouldn't really use cookies for logins - use the $_SESSION variable instead. session_start(); on each page (as the very first code) and then something like: if (($username == $db_username) && ($password == $db_password)) { $_SESSION['logged_in'] = 'true'; } else { $_SESSION['logged_in'] = ''; } then later you check for the $_SESSION['logged_in'] variable and the value, etc.
What cookie is gone? all cookies including login and cart? if so, then check the your login scritp and/or browser setting (allow/disallow cookie). Does PoPSiCLe's solutions work?
I understand in a matter of preference, some users prefer sessions to cookies, but why do you say that you "shouldn't really use cookies"? They are just as efficient, and many major sites still uses cookie-based login to-date.
Guys, this harryoxford guy is a spam bot, no need to reply to him You see he has created 18 threads in this forum in a very fast amount of time. As well, you'll see that every one of his threads comes from sitepoint (from different users): http://www.sitepoint.com/forums/showpost.php?p=4370170&postcount=1 http://www.sitepoint.com/forums/showpost.php?p=4364773&postcount=1 -> http://forums.digitalpoint.com/showthread.php?t=1502154 etc etc
The main reasons are security, the fact that sessions (might be) easier to use etc. Some links: http://www.tuxradar.com/practicalphp/10/1/0 http://www.phpshare.org/articles/Cookies-versus-Sessions.html Basically, you don't want to share login-info in cookies on the user's computer, as cookies can be changed by the user, or hijacked quite easily.