Help with restoring data using PHP sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dreagose
Forum Newbie
Posts: 15
Joined: Wed Sep 02, 2009 9:28 am

Help with restoring data using PHP sessions

Post by dreagose »

I have another problem, again, I am VERY much a newbe at PHP.

After the customer selects the item they want to purchase, the data is handed off to an outside cartserver service via a form.

Code: Select all

<form action='http://www.cartserver.com/sc/cart.cgi' onSubmit='javascript&#058;pageTracker._linkByPost(this)' method=POST>
that customer has the option to "continue shopping" and if he/she clicks it they are directed back to the page they were just at ie: the PHP generated page. At this time all they are getting is a blank page because the prior posted data that was passed to it no longer exists. I have been playing (trying to learn) with $_session[] but am currently not able to restore that data needed to rebuild the page. The data is a number and 2 letters from 3 different variables.

Can someone walk me through the process of restoring that data.
Oh, and I'm not allowed to use cookies.

Thanks a bunch in advance.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Help with restoring data using PHP sessions

Post by cpetercarter »

Do you really need to use session variables for this? An alternative would be a form with hidden fields containing the data you wish to pass back. The submit button could be the "Return me to the previous page" button which you already have. And because you would be submitting POST data, you can probably use the existing script to process the data and compute the web page.
dreagose
Forum Newbie
Posts: 15
Joined: Wed Sep 02, 2009 9:28 am

Re: Help with restoring data using PHP sessions

Post by dreagose »

The problem is that I have no control over the page that I'm submitting the data to.

The data is submitting to an outside shopping cart service that I have VERY limited choices on options. I'm trying to keep customers from using the "Continue Shopping" option that they give with a request on the PHP page but I would like to just solve the problem and not even worry about if they select it or not.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Help with restoring data using PHP sessions

Post by cpetercarter »

You say that you can't use cookies. Sessions are implemented by placing a cookie with the session id in the user's browser. Are you allowed to do that?
dreagose
Forum Newbie
Posts: 15
Joined: Wed Sep 02, 2009 9:28 am

Re: Help with restoring data using PHP sessions

Post by dreagose »

Unfortunately, no, it's against the site policy to use cookies. (some managers idea) but I've a workaround at the moment with a javascript redirect back to the first page for the product if no other solutions can be found.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Help with restoring data using PHP sessions

Post by jackpf »

You can pass the session id in the url.
dreagose
Forum Newbie
Posts: 15
Joined: Wed Sep 02, 2009 9:28 am

Re: Help with restoring data using PHP sessions

Post by dreagose »

Yes, I could but as I said in a previous post:
The data is submitting to an outside shopping cart service that I have VERY limited choices on options. I'm trying to keep customers from using the "Continue Shopping" option that they give with a request on the PHP page but I would like to just solve the problem and not even worry about if they select it or not.
I pass the session ID but it will just dump the info and it will not pass it back.
Post Reply