Troubles with cookies

    Date: 01/19/07 (PHP Community)    Keywords: php

    I'm having trouble setting up some cookies. It is a login form with a "remember me" option. If the user checks the "remember me" box, a cookie is set. If not, only session values are set.

    The problem the cookie is not being sent. This is my code ($info is the array holding the user information):

    if ($_POST['remember'] == 1) {
    $cookie_domain = "config set cookie_domain";
    $cookie_time = time()+60*60*24*365;

    setcookie("user_num_id", $info['id'], $cookie_time, "/", $cookie_domain);
    setcookie("user_id", $info['user_id'], $cookie_time, "/", $cookie_domain);
    setcookie("name", $info['name'], $cookie_time, "/", $cookie_domain);
    setcookie("remember", 1, $cookie_time, "/", $cookie_domain);
    }
    $_SESSION['user_num_id'] = $info['id'];
    $_SESSION['user_id'] = $info['user_id'];
    $_SESSION['name'] = $info['name'];
    $_SESSION['uid'] = session_id();
    $_SESSION['auth'] = 1;

    Header("Location: account.php");

    I suppose is some kind of header problem because, if I delete the "header" line, the cookie is set. This is meant to redirect the user to the account page after login. Anyone has a idea of why this isn't working? Thanks!

    Source: http://community.livejournal.com/php/532165.html

« Array for checkboxes? || ADOdb (Lite) Error Reporting »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home