Google Chrome forgetting registration cookie immediately

Posted by Ryan Giglio on Stack Overflow See other posts from Stack Overflow or by Ryan Giglio
Published on 2010-04-26T18:34:38Z Indexed on 2010/05/08 20:28 UTC
Read the original article Hit count: 149

I'm having trouble with cookies on my site's registration form.

When a user creates an account, PHP sets one cookie with their user id, and one cookie with a hash containing their user agent and a few other things. Both of these cookies are set to expire in an hour.

This is the code that sets the cookie after creating your account

$registerHash = hash( "sha512", $_SERVER['HTTP_USER_AGENT'] . $_SERVER['HTTP_HOST'] . $_SERVER['DOCUMENT_ROOT'] );

setcookie("register_user_id", $newUserID, time() + 7200, "/");
setcookie("register_hash", $registerHash, time() + 7200, "/");

The next page is a confirmation page which sends an email and then optionally lets the user go on to fill out more account information. If the user goes on to fill out more, it uses the cookie to know what account to save it to. It works correctly in Firefox and IE, but in Chrome the cookie is forgotten as soon as you go to the next page. The cookie simply doesn't exist.

You can see the problem here: http://crewinyourcode.com/register/paid/

If you use Chrome, you will get a registration timeout error as soon as you try to advance past the confirmation page. However on Firefox it works fine.

© Stack Overflow or respective owner

Related posts about google-chrome

Related posts about cookies