• Hi all,

    I’m currently working on a survey project. The user is invited to complete a form to create an account on our database for all their answers to be stored etc. The “Create an Account” form is an external form called TypeForm that is embedded within a page. Once the users submits the form TypeForm sends a webhook to our server, which is working perfectly and I can see the results of the PHP session variable (storing the e-mail address) in the response from our web-server back to TypeForm. When the page is automatically redirected, after the user submits the form, the PHP session variable is lost on the next page. It’s definitely lost between the redirects of the page and I’m not 100% sure why. I’ve even tried creating an automatic Ajax call to send the e-mail address to the next page, however, the same happens I can see it on the initial page, but the data in the variable is lost once the page is re-directed.

    In plan text this is the process:

    User Completes Form -> Form Responses are recognised by TypeForm -> TypeForm Sends Webhook -> Web-server Responds to Webhook -> Page Re-directs -> Variable is lost.

    The webhook is sent to a WordPress page, however, the functions that run the webhook are on the themes page.php and then the PHP session variable is sent to a plugins page.

    Could anyone please be any assistance on how I may be able to resolve this issue?

    If you require any additional information, please let me know.

    Thanks,
    Nathan

Viewing 8 replies - 1 through 8 (of 8 total)
  • Is it truly a session variable? Or is it a query variable?
    Can you outline the process again, but include which server is responding to each part? (like is Typeform in an iframe or is it javascript?)

    Form page is on your host, containing ___ that talks to a Typeform host?
    Form is submitted to ___ host, ___ variable is holding email

    Thread Starter nathanjb00

    (@nathanjb00)

    Hi @joyously,

    Thank you for your reply. I believe this has been created as a $_SESSION variable.

    Please see the process again, but this time with what server is responding to each part.

    User Submits their Form (This is sent to TypeForm) -> Webhook is sent to webserver (This is sent from TypeForm to Webserver) -> Webserver responds to TypeForm confirming that we’ve received the webhook (Webserver to TypeForm).

    “Form page is on your host, containing iframe that talks to a Typeform host?
    Form is submitted to TypeForm host, $_SESSION[“email”] variable is holding email on our webserver until the page re-directs”

    OK, so you don’t know. (what you are describing two ways contradicts each other)

    What needs to happen is the code on your site that handles the user input needs to set the session variable. The code that shows the form and uses the input values needs to check the session variable for values. The session variable lives on your site, not any other.

    Thread Starter nathanjb00

    (@nathanjb00)

    @joyously I’m unsure how my two process contradict each-other. The form is hosted on our website. TypeForm receives the responses when the user submits the form. TypeForm sends the responses in a webhook to our website, which at this point the e-mail address is stored from the webhook in a session variable on our website. The session variable doesn’t go anywhere else apart from our website.

    For reference: https://www.php.net/manual/en/book.session.php

    “Note: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser.”
    This means your plugin must handle the session stuff before the theme template is loaded.

    Thread Starter nathanjb00

    (@nathanjb00)

    @joyously Thank you! I will look on how the sessions are loaded and will feedback my findings.

    Thread Starter nathanjb00

    (@nathanjb00)

    @joyously I’ve tried starting the session before the theme template loaded and it didn’t change my results. I’m still not getting the session variable. I can confirm that the session variable data is their before the page redirects, however, is lost after the page redirects.

    You don’t mention any specifics, but you have to start the session, set the variable and close the session. Then the other stuff happens in a different request, so that code also has to start the session, read the variable and close the session.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘PHP Sessions Variable Assistance’ is closed to new replies.