Professional Web Applications Themes

problem with session cookie - PHP Development

I'm currently trying to build an online store, and am using sessions to track a particular visit. Once the purchase has been completed I want to destroy the session, and remove the session cookie from the browser (this being particularly important to avoid the same session id being reused if the user decides to place a second order). After the purchase is completed I have some PHP code,in a script called completedtrx.php which contains setcookie("PHPSESSID", '', time()-42000, '/'); session_unregister("id"); session_destroy(); and then goes on to echo a thankyou message. All works as a had hoped, when all the scripts are ...

  1. #1

    Default problem with session cookie

    I'm currently trying to build an online store, and am using sessions to
    track a particular visit.

    Once the purchase has been completed I want to destroy the session, and
    remove the session cookie from the browser (this being particularly
    important to avoid the same session id being reused if the user decides to
    place a second order).

    After the purchase is completed I have some PHP code,in a script called
    completedtrx.php which contains

    setcookie("PHPSESSID", '', time()-42000, '/');
    session_unregister("id");
    session_destroy();

    and then goes on to echo a thankyou message. All works as a had hoped, when
    all the scripts are located on my server .

    BUT

    I want to enable online credit card processing, and so script execution
    leaves my server, runs on the credit card gateway, and then the gateway
    returns the browser to www.myserver.com/completedtrx.php .

    When this happens the cookie is not destroyed, unless I refresh the page
    www.myserver.com/completedtrx.php in the browser.

    How do I delete the cookie in these cirstances?


    David Guest

  2. #2

    Default Re: problem with session cookie

    David Groom wrote: 
     

    Hi

    In most cases you're able to send custom data to the credit card company
    which they are posting back to you. So you can send the session_id or
    an id from which you are able to get the session_id. Ask your credit
    card company.

    By the way, you should start a session at the beginning of your script

    start_session();

    session_unregister("id");
    session_destroy();


    Regards
    Stefan

     
    Stefan Guest

  3. #3

    Default Re: problem with session cookie

    Stefan Rybacki wrote: 

    >
    >
    > Hi
    >
    > In most cases you're able to send custom data to the credit card company
    > which they are posting back to you. So you can send the session_id or
    > an id from which you are able to get the session_id. Ask your credit
    > card company.
    >
    > By the way, you should start a session at the beginning of your script
    >
    > start_session();[/ref]

    I meant

    session_start();

    sorry.
     [/ref]
    Stefan Guest

  4. #4

    Default Re: problem with session cookie

    "Stefan Rybacki" <net> wrote in message
    news:net... 
    >> 
    >>
    >>
    >> Hi
    >>
    >> In most cases you're able to send custom data to the credit card company
    >> which they are posting back to you. So you can send the session_id or an
    >> id from which you are able to get the session_id. Ask your credit card
    >> company.
    >>
    >> By the way, you should start a session at the beginning of your script
    >>
    >> start_session();[/ref]
    >
    > I meant
    >
    > session_start();
    >
    > sorry.
    > [/ref]


    Stefan
    I do have the session_start() in my script, the code I included in my
    original script was just and extract from that script.

    But my problem is not that I can't perpetuate the session id after coming
    back from the credit card company. My problem is that I want to delete the
    cookie from the users' browser, and at present I am trying to do this from
    within the script that is called from the credit card gateway's
    confirmation.

    David


    David Guest

  5. #5

    Default Re: problem with session cookie

    David Groom wrote: 
    >>
    >>I meant
    >>
    >>session_start();
    >>
    >>sorry.
    >>
    >> [/ref]
    >
    >
    >
    > Stefan
    > I do have the session_start() in my script, the code I included in my
    > original script was just and extract from that script.[/ref]


    Ok sorry, didn't know that.
     

    You said the cookie isn't deleted until refreshing the page, so why do
    it by script?

    1. You could delete the setcookie as you did and redirect to the page
    again with a parameter that prevents the script from doing the redirect
    again and again ...

    2. May it is enough to call the initial script a completetrx.php and
    redirect to for example thankyou.php


    Stefan
     
    Stefan Guest

  6. #6

    Default Re: problem with session cookie

    you and I were thinking along the same lines, I was just re-coding it as you
    wrote your post !

    --
    blank
    "Stefan Rybacki" <net> wrote in message
    news:net... 
    >>
    >>
    >>
    >> Stefan
    >> I do have the session_start() in my script, the code I included in my
    >> original script was just and extract from that script.[/ref]
    >
    >
    > Ok sorry, didn't know that.

    >
    > You said the cookie isn't deleted until refreshing the page, so why do it
    > by script?
    >
    > 1. You could delete the setcookie as you did and redirect to the page
    > again with a parameter that prevents the script from doing the redirect
    > again and again ...
    >
    > 2. May it is enough to call the initial script a completetrx.php and
    > redirect to for example thankyou.php
    >
    >
    > Stefan
    > [/ref]


    David Guest

  7. #7

    Default Re: problem with session cookie

    David Groom wrote: 

    Cool, let me know whether it worked or not and which version you have
    implemented.

    Thanks
    Stefan
    Stefan Guest

Similar Threads

  1. Replies: 2
    Last Post: October 10th, 12:07 PM
  2. Replies: 0
    Last Post: September 22nd, 04:25 PM
  3. Cookie/Session problem
    By Peter Young in forum ASP
    Replies: 1
    Last Post: September 13th, 11:37 PM
  4. #25465 [Opn]: Session lost, session.cookie.lifetime
    By sam dot houlder at teleperfomance dot no in forum PHP Development
    Replies: 0
    Last Post: September 10th, 07:13 AM
  5. authentication cookie vs session cookie
    By Joseph in forum ASP.NET Security
    Replies: 4
    Last Post: August 12th, 10:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139