/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@pyroJul 07.2003 — Take a look at http://us3.php.net/manual/en/ref.session.php for info on sessions.
Copy linkTweet thisAlerts:
@ceanthauthorJul 07.2003 — 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?
Copy linkTweet thisAlerts:
@pyroJul 07.2003 — For the time and date, it depends on the format. Info can be found [URL=http://us3.php.net/date]here[/URL]. And, to get an IP address, you use $_SERVER["REMOTE_ADDR"]
Copy linkTweet thisAlerts:
@ceanthauthorJul 08.2003 — 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?
×

Success!

Help @ceanth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...