dongyata3336
2017-08-12 09:24
浏览 22
已采纳

如何在嵌入式文件中使用php会话?

I have a site https://one.com/go.php that (for example) contains :

session_start();
$_SESSION['id_ad'] = 123456;
header('Location: https://two.com/index.php');

and on https://two.com/index.php user click and go to https://three.com/index.php that contains :

<script type="text/javascript" src="https://one.com/2.php"></script>

and finally 2.php is:

 <?php
session_start();
header("Content-Type: application/javascript");
?>
alert("<?=$_SESSION['id_ad']?>");

can i access $_SESSION['id_ad'] in 2.php ? I tested only on firefox works.

////////EDIT//////

thank you to @Dimash to mention my mistake, but the main question still exists

图片转代码服务由CSDN问答提供 功能建议

我有一个网站 https://one.com/go.php (例如)包含:

  session_start(); 
 $ _SESSION ['  id_ad'] = 123456; 
header('Location:https://two.com/index.php');
nn

https://two.com/index.php 用户点击并转到 https://three.com/index.php 包含:

 &lt; script type =  “text / javascript”src =“https://one.com/2.php”&gt;&lt; / script&gt; 
   
 
 

最后2.php是 :

 &lt;?php 
session_start(); 
header(“Content-Type:application / javascript”); 
?&gt; 
alert(“&lt;?  = $ _ SESSION ['id_ad']?&gt;“); 
   
 
 

我可以在2中访问 $ _ SESSION ['id_ad'] .php? 我只在firefox上测试过。

////////编辑//////

谢谢 到@Dima 提到我的错误,但主要问题仍然存在

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题