session id for a cart online shopping.

Discussion in 'PHP' started by Kyriakos, May 5, 2008.

  1. #1
    hi,

    i want to create a cart in my site and i want the system gives an automatically sessionID to each user who uses the cart.
    <html>
    <head>
    <%
    VarsessionID=session.SessionID
    %>
    </head>
    <body>
    <%
    sqladdtocart="INSERT INTO cart (sessionid,product_id,price ) VALUES ( '"&Varsessionid&"','"&prod_id&"','"&price&"',)"
    Con.Execute sqladdtocart
    %></body>
    </html>
    HTML:
    this is my ASP code. all is working fine except of sessionId. i want this sessionID to expire after one hour.
     
    Kyriakos, May 5, 2008 IP
  2. WebGodzilla

    WebGodzilla Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you're writing ASP, why did you put this question in PHP forum? Report it to moderator and let him move it in the ASP forum.
     
    WebGodzilla, May 5, 2008 IP
  3. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    i want to translate this code to php man. i'm not stupid.
     
    Kyriakos, May 5, 2008 IP
  4. adrevol

    adrevol Active Member

    Messages:
    124
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #4
    may be this user defined function will help you

    private function startSession($time = 3600, $ses = 'MYSES') {
        session_set_cookie_params($time);
        session_name($ses);
        session_start();
    
        // Reset the expiration time upon every page load
        if (isset($_COOKIE[$ses]))
          setcookie($ses, $_COOKIE[$ses], time() + $time, "/");
    }
    Code (markup):
     
    adrevol, May 5, 2008 IP
  5. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    i want to expire cookie when user closes the browser
     
    Kyriakos, May 6, 2008 IP