0

I want to be able to write some data to the PHP session AFTER the page has loaded, and BEFORE the page proceeds to the next page.

for example, this is a PHP file:

<input type="text" value="abc" />
<input type="button" onClick="doSomething()" />

How do I write "abc" to the php session (or whatever the user has typed in the textfield) in the javascript function doSomething()? Is this possible?

1 Answer 1

2

you can use ajax to pass the value to php while the page is open

this was on the "related" sidebar on the right, for reference How to use jQuery AJAX $.post to store PHP $_SESSION variables?

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

2 Comments

Thank you, but is using AJAX the only way? Since the php has finished executing at loading time, I guess it is not possible to execute any php without refreshing the page right?
php is only executing against a request. with ajax you send a request while the page is open. else, you have to wait until page refresh/reload

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.