SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone know a good tutorial for handling more complex cookies? like for a shopping cart?

    All tutorials I've seen manages a single variable ($name or something like that)

    I need to know how to set up cookies with multiple variables (many $product_idīs), how to modify them (for example how to delete a single $product_id from a list of, letīs say, 20 product_idīs inside the cookie)(or how to insert a new one in the same list), How to get those variables from the cookie, How to store more data in the same cookie (is this possible?) for example: store $product_id and $atribute and $atribute_value just for the products that have atributes, etc.

    for example:

    2547 #product_id
    5478 material wood #product_id, atribute and atribute_value
    5847 #product_id
    4874 color blue #product_id, atribute and atribute_value

    This might sound dumb for all you guru guys, but any help on this will be appreciated

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The reason you're not seeing tutorials that show how to handle multiple and complex variables is that this is rarely done. Rather, you should set a single variable that identifies the user, and keep all the shopping cart information on the server-side in a database, identified with that user's unique ID (stored in the cookie).

    PHP sessions are ideal for this, as they automate the setting of that single variable and allow you to store as many variables as you like for the duration of a user's session.

    Check out my recent article, "Managing Users with PHP Sessions and MySQL", for a good introduction to Sessions. The application discussed is different, but it'll teach you the techniques you need.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that makes a lot of sense ,

    but i need to do this on PHP3, does PHP3 handle sessions?, if not, how to do this same thing on PHP3?

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't have native support for sessions but there is a library [url="http://phplib.netuse.de"]phplib[url] that can handle session data
    Last edited by freddydoesphp; Feb 20, 2001 at 18:39.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP3 does not have built-in support for session management; however, PHPLib does provide a similar (and arguably superior) facility.

    Oh looks like someone beat me to it.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, now i have my nose inside this article by Kevin Yank and is very interesting... but before i sit down and learn it all, will this help? or i need to go and learn what are and how to use Libraries first?

    Hey! how much does freddy charges for a PHP script?

    Thanks for the help guys! i really apreciate it

  7. #7
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Read the article first. It's not that long, and explains the concept behind sessions. Afterwards, you should be able to read the documentation for sessions in PHPLib and figure out how to convert the scripts in my article so they use the PHPLib session functions.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  8. #8
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Man itīs you!! i didnīt recognize you, hehehe in the article you have gleasses

    Let me tell you that i have printed your article "Building a Database-Driven Web Site Using PHP and MySQL", and it is my bible right now

  9. #9
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you know how to use classes and functions in PHP, then applying the theories taught in Kevin's tutorial should provide for the background you need to use PHPLib
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Iīm on 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
  •