0

Hopefully final question about sessions.

A page loads with data from a form. Some of the data is taken by a session for the next page. Meanwhile on this page a form field called 'GT_specifications' is inside a form. It s data is updated towards the end of the page with a JQUERY script that puts .html() of a div inside it. This value then needs to go into the SESSION as well. I tried

<?php $_SESSION['booking-form-specifications'] = $_POST['GT_specifications'] ?>

after the script is activated at the bottom of the page but it did not work.

Any ideas?

Marvellous

CLARIFICATION "DID NOT WORK"

The value of GT_specifications does not go into the session as on the other side the echo of $_SESSION['booking-form-specifications'] does not equal the value of GT specifications when the session is recalled. All other sessions are working fine. The value of $_SESSION['booking-form-specifications'] has to be taken from a form field on this page not loaded in on load and I think that is the problem. So $POST['GT_specifications'] is wrong as that field has not be posted. We need to get the value of the field named 'GT_specifications'] on this page not one posted in.

4
  • Clarification above, I think I know why it does not work. Take a look at my clarification. I still do not know how to sort it out. Commented Feb 4, 2011 at 13:16
  • the word "bottom" looks like VERY suspicious. Sounds like you do not understand what's going on in the server <-> client system. If so, it should be your concern in the first place Commented Feb 4, 2011 at 13:22
  • Please read the question before you comment. There is a jquery script towards the end of the page that determines what the value of 'GT_specification' is. At the top of the page is the standard session_start(); and a few Session values are determined there but we need the value of specifications to be taken from a field on this page called 'GT_specifications'. The problem is that value is not known till after a JQuery script occurs at the bottom of the page. Commented Feb 4, 2011 at 13:26
  • To tell you truth, there is no such thing like separate "bottom". A page always executes from the top. Commented Feb 4, 2011 at 13:54

2 Answers 2

1

You forgot to call session_start();

Sign up to request clarification or add additional context in comments.

3 Comments

That is called at the top of the page with the session
need to be called in script containg $_SESSION['booking-form-specifications'] = $_POST['GT_specifications']
Clarification above, I think I know why it does not work. Take a look at my clarification. I still do not know how to sort it out.
0

I'm not sure i understand your question.

Do you update the page with javascript before submitting? Or do you do it after, if you do it after - why use javascript to change the content at all, could just do it with PHP when you serve the page.

If you do it with javascript before an actual submit, you can't set a session. A session needs to happen serverside and would happen before the page is served to the browser - you cannot combine javascript and a php session without submitting this data to the server and then saving (via AJAX or form submit)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.