Click to See Complete Forum and Search --> : SID information and examples please


ceanth
07-07-2003, 12:25 PM
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

pyro
07-07-2003, 12:33 PM
Take a look at http://us3.php.net/manual/en/ref.session.php for info on sessions.

ceanth
07-07-2003, 12:52 PM
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?

pyro
07-07-2003, 12:55 PM
For the time and date, it depends on the format. Info can be found here (http://us3.php.net/date). And, to get an IP address, you use $_SERVER["REMOTE_ADDR"]

ceanth
07-08-2003, 09:02 AM
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?