-
October 16th, 2009, 05:11 AM
#1
Webshop
Hello Everyone,
I'm building a webshop. I have to track the user's navigation on the website and i have to create a "shoppingcart". What is the best way to approach this. Should i use Cookies or Sessions or a combination. Can anyone please point me in the right direction.
Thank you.
-
October 16th, 2009, 07:12 AM
#2
Re: Webshop
First off, why not use an already existing software solution? Commerce web apps are large scale and take quite some time to develop. Why not work with ones already completed? There are several free solutions...http://sourceforge.net/search/?words...ewfilter=Apply
If you absolutely have to write it yourself...most shopping cart projects use both cookies and sessions along with a database. Cookies store the session ID. Sessions store temporary data. Databases store the long-term information. One of the annoyances with shopping carts is that you have to accommodate for people having an item in their cart and someone else purchasing it before they have the chance to checkout. That is another reason why I suggest you use already completed software.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
October 17th, 2009, 07:36 AM
#3
Re: Webshop
Thanks for the reply,
it has to be a simple webshop, and i can't use a opensource solution because this project is for a exam for my college. iv'e gor the database filled with products and such, i also got a database structure, all i have to do now is creating a shoppingcart system with cookies and session, i just don't knwo where to start. The payment module has been taken care of already also.
Can you please point me in the right direction how to start with cookies and session i would appreciate it very much.
Thanks,
-
October 17th, 2009, 09:39 AM
#4
Re: Webshop
As long as your database structure includes unique IDs (which it should), just store the IDs and quantity in some session data named cart. Then, at checkout, make sure that the quantity match with the actual stock.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
October 17th, 2009, 12:18 PM
#5
Re: Webshop
Thank you , actually; i don't need to create a stock inventory. I was thinking to use Temporary XML files on the server to store the shoppingcart data. What do you think about that approach ?
Thanks.
-
October 17th, 2009, 12:27 PM
#6
Re: Webshop
Creating extra files on the server leads to disk fragmentation and extra disk usage. Session data would be much more efficient.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
October 18th, 2009, 09:26 AM
#7
Re: Webshop
Should i use Sessions or cookies?,
In theory are they the same ?
-
October 18th, 2009, 02:43 PM
#8
Re: Webshop
Same in function, not same in implementation. As I mentioned earlier, you should use both...store the session ID in the cookie, but use the session to store the information. This is much more secure!
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
October 19th, 2009, 03:35 AM
#9
Re: Webshop
Thank you, Why should i put the sessionID in a Cookie, why can't i just GET the sessionId with session_id(); ?
-
October 19th, 2009, 10:07 AM
#10
Re: Webshop
If multiple people are using this system, how do you plan to track who has what session? Or, instead of using session_id(), you could just use session_name() and drop the whole cookie.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
October 20th, 2009, 03:10 AM
#11
Re: Webshop
Thank you,
does a session name need to be unique for every user? i plan to create a unique session name for every visitor that enters the site. Then i'll save the data in the database with the session name as key.
So when a visitor enters the site a function will check if a session_name is set ( by checking if the default session name is used ) is the default session name is used then a unique sesison name will be generated and logged in the database.
Is this a good approach ?
-
October 20th, 2009, 06:55 AM
#12
Re: Webshop
No. Session names do not have to be unique. The server will take care of the unique connection for you.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|