boop
boop

Reputation: 7788

Is it possible to store a variable in a PHP script that's called by AJAX?

Simple question: When I call an PHP script by AJAX - is it possible to store a variable for the next call(s)?

I would like to avoid using a cookie for this.

Upvotes: 0

Views: 62

Answers (2)

Pratap Patil
Pratap Patil

Reputation: 234

When you are calling php code from AJAX function means your page is not refreshing so you can store the values in hidden field for next call. Or you want those values for another pages or after page refresh as well then you need to check with $_Session["Session_name"];

Thanks

Upvotes: 0

Jazi
Jazi

Reputation: 6732

You can store data in a JavaScript variable. Second option, is to store data in database or a file. PHP $_SESSION variable should work too.

Upvotes: 3

Related Questions