Results 1 to 5 of 5

Thread: ebay's track what you've view

  1. #1
    Join Date
    Jun 2007
    Location
    Hollywood
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ebay's track what you've view

    I often use shopping carts as a memo list generator. I add to cart the products, view cart and print. I've noticed lately many shopping carts don't require an account to do this. You can just add and view right away.

    I only need to track the item not anything else. Like ebay's track what you've view with out logging in. Is this possible with js and cookies instead of a db.

    thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You could do this using cookies in Javascript, but that wouldn't be entirely reliable and would be a somewhat complicated script.

    The best way to do this would be to use a PHP session (or something equivalent in another serverside language). A session is basically a single "visit" to the website, and during that time if you're using "sessions" in PHP you can store variables. So as you visit pages, just add that page to the list of visited pages and it'll be available on the next page.

    Sessions are sort of like simple databases, but they aren't permanently stored anywhere-- just temporarily on the server while that user keeps loading pages. After a period of inactivity the data is cleared from the server.

    So just like cookies, sessions don't store the data forever (and shouldn't be relied on for permanent information) but do a great job of having an easy place to keep "notes" about what a user is doing during a visit to the site.

    The best thing about sessions in PHP is that they're very easy to use, definitely easier than cookies. Of course you need to know a little about PHP to be able to use them, but if you can deal with that, it's your easiest option.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2011
    Posts
    34
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Could you not "stage" the data on the client with localstorage, then if they want to make the order they "submit" it to the server with the php?

  4. #4
    Join Date
    Jun 2007
    Location
    Hollywood
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    djr33,

    Very Good, now I know where to start my search. It's hard to find something when you don't know where it is. I will look into "sessions in PHP"

    djr33 THANKS for your time and knowledge.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Since you're going to use sessions, here's a very quick tutorial. Luckily, sessions are one of the easiest things you could want to learn:

    1. For some complicated reasons, sessions need to be activated before there is any output (even a single new line) sent to the browser. Also, they should be used on all pages (even if you're not actively using them) for consistency and to keep the session active during the visit to your site. So, just add the following code to the very top of all of your pages:
    PHP Code:
    <?php session_start(); ?>
    2. Once sessions are active, you can use the array $_SESSION to store any information you'd like, any time, on any page, and it will remain active throughout your entire site during the single session for that user. Here's some example code:
    PHP Code:
    <?php
    $_SESSION
    ['myvariable'] = 'Hello!';

    //a while later, or on another page:
    echo $_SESSION['myvariable']; //print out "Hello!"
    ?>

    Note: sessions are secure, or at least the data is. No one else can access the data stored in the session, and even the user cannot (as they could with a cookie) unless you choose to output it for them.


    Of course you'll need to learn a little more about PHP to deal with things like creating a list of pages they've visited and displaying it in a nice format, but that's really all you need to know about sessions (at least for now).
    One very basic point: PHP is basically the same thing as HTML, but it does require that your server has PHP installed and enabled-- most do. Then you need to use the .php extension instead of .html so that the server knows to go through the PHP code. But aside from that, .php is functionally the same as HTML-- what the browser sees is the same as an HTML page (it IS an HTML page, actually). So, for example, you could just rename any HTML page on your site .php and it would be fine. (There's no need unless you want to use PHP on it, though.)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •