简体   繁体   中英

Pass Session variable to the ajax called PHP script

While using the sessions in my PHP script I wanted to pass the session variable to the PHP called script. But the session variables are not being called as the session_start() function could not be used after the HTML code. I am using the simple Javascript AJAX. Please provide me the path.

I think what you need is the following:

in your php-script you open/request with ajax, you have to add in the first line:

session_start(session_id());

This way, you have access to the variables you stored in your session where you called the request with ajax

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM