www.webdeveloper.com
Results 1 to 5 of 5

Thread: SID information and examples please

  1. #1
    Join Date
    Jun 2003
    Location
    London
    Posts
    14

    SID information and examples please

    i am creating a shopping cart setup but without the use of cookies. I am planning on the following setup:

    page1. search results
    page2. cart
    page3. cart summary before order is complete.

    Ok now page1 is fine. With page2 i am planning on adding items into the table cart but also i need to a unique id so that i can reference the session to the cart. I have heard of SIDs (session ids) which i think i can use.

    If i create a session and session id when the user enters the site, when they place an item into the cart add the id along with the product into the cart table. Then retreve the cart details via the session id, so hopefully when the user views cart it will use the session they are on. Also i hope the remove cart entries when page3 is confirmed (again can use session id).

    So what i need to know is how exactly do i create session id's? Also how can i find out the session id when its created (so i can reference it), i plan on starting (and hopefully finishing) this tomorrow so if anyone can post some ideas for me to try out i can test them out 2morw.

    thanks

    ceanth

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Take a look at http://us3.php.net/manual/en/ref.session.php for info on sessions.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Jun 2003
    Location
    London
    Posts
    14
    umm interesting, i could use somethig like

    $id = time, date, ipaddress;
    session_id($id);

    just being lazy here but how do i get the time, date and ipaddress of the user?

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    For the time and date, it depends on the format. Info can be found here. And, to get an IP address, you use $_SERVER["REMOTE_ADDR"]

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  5. #5
    Join Date
    Jun 2003
    Location
    London
    Posts
    14
    Im trying to pass on a sessionid which i have created but it doesnt seem to pass. This is the setup:

    page1.php

    <?
    $time = time();
    $date = $today = date("Ymd");
    $id = $time + $date;

    session_id($id);
    session_start();

    print session_id();
    echo "time = $time";
    echo "date = $date";
    ?>

    This works fine giving me the id.

    Page2.php

    <?
    session_start();
    print session_id();
    echo "time = $time";
    echo "date = $date";
    ?>


    This does not display the information from the first page. Any ideas anyone?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles