Results 1 to 3 of 3

Thread: [resolved] setcookie, more than one variable?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Resolved [resolved] setcookie, more than one variable?

    Hello all.
    How would I go about setting another name-value pair within a cookie? I can't figure out the correct syntax. So far I have:
    Code:
    setcookie("user_id", '.$row->user_id.', time()+86400);
    Any help is greatly appreciated.
    Last edited by solitario; May 27th, 2005 at 02:53 PM.

  2. #2
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: setcookie, more than one variable?

    why not just set a cookie array?

    PHP Code:
    <?php
    // set the cookies
    setcookie("cookie[three]""cookiethree");
    setcookie("cookie[two]""cookietwo");
    setcookie("cookie[one]""cookieone");

    // after the page reloads, print them out
    if (isset($_COOKIE['cookie'])) {
       foreach (
    $_COOKIE['cookie'] as $name => $value) {
           echo 
    "$name : $value <br />\n";
       }
    }
    ?>
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Re: setcookie, more than one variable?

    Thank you ALL.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width