简体   繁体   中英

Accessing session variables in a php file using javascript?

I want to know if there is a way to access the variables set by php using java-script, so that on one page the php variables are set. And then on the next page, i can use java-script to interrogate the PHP file in order to extract the variables, so that they can be displayed on another page?

Thanks in advance!

不确定这是否有效,适用于我的get和post变量

var mySessionVariable = "<?php echo $_SESSION['sessionVariable']; ?>";

唯一的方法,你会这样做,是通过设置PHP(或Javascript)的cookie,并访问这些..您可以使用$_COOKIE['var']通过PHP访问cookie,并通过Js by, document.cookie("var")

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