#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    20
    Rep Power
    0
    Sir im using the following code to store cookies into the client computer but it works on some machine . i don;t know why it;s not working on the same machin which is accepting java cookeis but not accepting php cookeis

    here is the code

    setcookie("computerid",$computerid,time()+94608000,"/","www.mycompany.com","");


    Plzx help me
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    2
    Rep Power
    0

    I had the same problem recently. Lynx recognized my cookies but netscape or exploder not.
    There is something special with cookies format?


    ------------------

    Belu Bogdan - cobra@ines.ro
    webmaster
    INES Internet
  4. #3
  5. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    jdma79,

    see,first whether your cookie is set or not.
    Another reason,
    Probably your clients computer must have switched off the cookie option.

    for checking whether cookie is successfully you can use:
    if(isset($computerid)){
    print "Cookie is setn";
    }


    Visit the following link for solving your problem...
    http://www.phpbuilder.com/manual/fun...setcookie.php3


    GOOD LUCK!!!

    ------------------
    SR -
    shiju.dreamcenter.net
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    Here is code to test the ability to save a cookie on a browser. Also note some useful methods of storing cookies. This is a compilation of tips and tricks found on php.net. Works on Linux, 95, 98 ,NT IE 4 and Netscape 4.5-

    <?
    function store_array_in_cookie($cookiename, $array2store) {
    $tmpstring = serialize($array2store);
    setcookie($cookiename, $tmpstring, time()+3600*5, "/");
    unset($tmpstring);
    }

    function erase_array_in_cookie($cookiename, $array2store) {
    $tmpstring = serialize($array2store);
    setcookie($cookiename, $tmpstring, time()-3600*5, "/");
    unset($tmpstring);
    }
    function erase_set_array_cookie($cookiename, $array2store) {
    $tmpstring = serialize($array2store);
    setcookie($cookiename, $tmpstring, time()-604800, "/");
    setcookie($cookiename, $tmpstring, time()+604800, "/");

    unset($tmpstring);
    }
    function erase_set_array_cookie_header($cookiename, $array2store) {
    $time = mktime()+36000;
    $backtime = mktime()-36000;
    $date = date("l, d-M-y H:i:s", ($time));
    $backdate = date("l, d-M-y H:i:s", ($backtime));
    $tmpstring = serialize($array2store);
    $tmpstring = urlencode($tmpstring);
    // header("Set-Cookie: $cookiename=$tmpstring; expires=$backdate GMT; path=/; domain=.biospectra.netn");
    // header("Set-Cookie: $cookiename=$tmpstring; expires=$date GMT; path=/; domain=.biospectra.netn");
    // header("Location: <A HREF="http://www.biospectra.net/index.php3n");" TARGET=_blank>http://www.biospectra.net/index.php3n");</A>
    // exit;

    header("Set-Cookie:$cookiename=$tmpstring;expires=$backdate GMT;path=/nSet-Cookie:$cookiename=$tmpstring;expires=$date GMT;path=/");
    unset($tmpstring);
    }
    function erase_cookie_header($cookiename, $array2store) {
    $backtime = mktime()-36000;
    $backdate = date("l, d-M-y H:i:s", ($backtime));
    $tmpstring = serialize($array2store);
    $tmpstring = urlencode($tmpstring);
    header("Set-Cookie: $cookiename=$tmpstring; expires=$backdate GMT; path=/");
    unset($tmpstring);
    }
    function store_cookie_header($cookiename, $array2store) {
    $time = mktime()+36000;
    $date = date("l, d-M-y H:i:s", ($time));
    $tmpstring = serialize($array2store);
    $tmpstring = urlencode($tmpstring);
    header("Set-Cookie: $cookiename=$tmpstring; expires=$date GMT; path=/");
    unset($tmpstring);
    }
    function get_array_from_cookie($cookiename) {
    $tmpstring = "global $$cookiename";
    eval($tmpstring);
    unset($tmpstring);

    if (isset(${$cookiename})) {
    $tmparray=unserialize(stripslashes(${$cookiename}));
    } else {
    $tmparray = array();
    }
    while (list($name, $value) = each($tmparray))
    printf("type="hidden" name="%s" value="%s"<BR>n", $name, $value);
    return $tmparray;
    }
    $cookiename="cookiearray";
    if (!($submit_store == "")) {
    $array2store=array(bbaez,nim101,15,0,0);
    store_array_in_cookie($cookiename, $array2store);
    };
    if (!($submit_erase == "")) {
    $array2store=array(bbaez,nim101,15,1,1);
    erase_array_in_cookie($cookiename, $array2store);
    };
    if (!($submit_erase_store_set == "")) {
    $array2store=array(bbaez,nim101,15,1,1);
    erase_set_array_cookie($cookiename, $array2store);
    };
    /**********************************************************************************/
    if (!($submit_store_header == "")) {
    $array2store=array(bbaez,nim101,15,0,0);
    store_cookie_header($cookiename, $array2store);
    };
    if (!($submit_erase_store_header == "")) {
    $array2store=array(bbaez,nim101,15,1,1);
    erase_set_array_cookie_header($cookiename, $array2store);
    };
    if (!($submit_erase_header == "")) {
    $array2store=array(bbaez,nim101,15,1,1);
    erase_cookie_header($cookiename, $array2store);
    };
    /**********************************************************************************/
    if (!($submit_retrieve == "")) {
    get_array_from_cookie($cookiename);
    };
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>

    <BODY BGCOLOR="#FFFFFF">
    <form action="<? echo $PHP_SELF ?>" method="POST">

    <input type="submit" name="submit_store" value="Click To Store">
    <input type="submit" name="submit_erase_store_set" value="Click To Erase and Store Using setcookie()">
    <input type="submit" name="submit_erase" value="Click To Erase">
    <P>
    <P>
    <input type="submit" name="submit_store_header" value="Click To Store Using the Header">
    <input type="submit" name="submit_erase_store_header" value="Click To Erase and Store Using Header">
    <input type="submit" name="submit_erase_header" value="Click To Erase Using the Header">
    <P>
    <P>
    <input type="submit" name="submit_retrieve" value="Click To Retrieve">
    </form>
    </BODY>
    </HTML>

Similar Threads

  1. hard drive problem?! plz help me
    By REZA's in forum Windows Help
    Replies: 3
    Last Post: February 11th, 2004, 06:54 PM
  2. session object variable problem... urgent plz
    By hatembr in forum ASP Programming
    Replies: 2
    Last Post: February 11th, 2004, 02:14 AM
  3. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 02:21 PM
  4. sendmail problem, any advice plz?
    By davun in forum Perl Programming
    Replies: 4
    Last Post: January 25th, 2004, 07:32 PM
  5. Session Variable problem :(
    By modesty in forum PHP Development
    Replies: 1
    Last Post: January 15th, 2004, 04:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo