SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot Mr Chocolate's Avatar
    Join Date
    May 2002
    Location
    Australia
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cookies wishlist

    Hello,

    I want to make a wishlist on my site and i want to use cookies. I don't want people to have to register or anything that's why i'm not using sessions.

    I just want to use one cookie that stores the Id's of the properites. so when someone clicks on the add to my wishlist link the cookie is updated with that Id. I have never used cookies before in my life so that's where the problem begins.

    I read some where you can do this something like this.

    PHP Code:
     
    setcookie
    ('mycookie'$Id_one.'|'.$Id_two); 
    Ok so thats where i'm at not very far , this is what i want do in point form

    • Allow user to add to wishlist
    • Allow user to delete items from wishlist
    • and use mysql's WHERE x IN (arg1, arg2, arg3) to select the properties in the wishlist and display them.

    do you know how to do this? if i don't make sence just let me know.

  2. #2
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hmmm...

    PHP Code:
    //set cookie
    $cookievar = array();
    setcookie('name',$cookievar,rest of cookie stuff);

    //add item
    $_COOKIE['name'] .= $id
    Maybe. I have no idea, just a wild guess
    Mike
    It's not who I am underneath, but what I do that defines me.

  3. #3
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    setcookie ("cookie[three]""cookiethree" );
    setcookie ("cookie[two]""cookietwo" );
    setcookie ("cookie[one]""cookieone" );
     
    print_r($_COOKIE['cookie']); 
    is one method, or this:
    PHP Code:
    $wishlist = array([WISHLIST ITEMS ARRAY]);
    setcookie("wishlist"serialize($wishlist));

    $readbackarray unserialize($_COOKIE['wishlist']); 
    Hope that helps.
    Last edited by cyborg from dh; Mar 31, 2003 at 01:16.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  4. #4
    SitePoint Zealot Mr Chocolate's Avatar
    Join Date
    May 2002
    Location
    Australia
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    PHP Code:
    setcookie ("cookie[three]""cookiethree" );
    setcookie ("cookie[two]""cookietwo" );
    setcookie ("cookie[one]""cookieone" );

    print_r($_COOKIE['cookie']); 
    is one method, or this:
    PHP Code:
    $wishlist = array([WISHLIST ITEMS ARRAY]);
    setcookie("wishlist"serialize($wishlist));

    $readbackarray unserialize($_COOKIE['wishlist']); 
    Hope that helps.
    thanks for the reply guys and so fast to. YIPPIE!! so you can use multiple cookies to keep my id's seperate correct?

    How do i add a propertyId value to a cookie ?

    And then how do i delete it?


Bookmarks

Posting Permissions

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