dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: Webshop

  1. #1
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    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.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    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.

  3. #3
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    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,

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    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.

  5. #5
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    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.

  6. #6
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    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.

  7. #7
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    Re: Webshop

    Should i use Sessions or cookies?,
    In theory are they the same ?

  8. #8
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    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.

  9. #9
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    Re: Webshop

    Thank you, Why should i put the sessionID in a Cookie, why can't i just GET the sessionId with session_id(); ?

  10. #10
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    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.

  11. #11
    Join Date
    Sep 2008
    Location
    The Netherlands
    Posts
    22

    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 ?

  12. #12
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)