使用Javascript创建/更新Php会话 [英] Create/Update Php Session with Javascript

查看:64
本文介绍了使用Javascript创建/更新Php会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Javascript创建/更新Php会话以确认

如果用户启用了Javascript。


我的第一个想法是创建一个写一个脚本标签的Javascript

引用一个php页面,它设置一个$ _SESSION变量。


javascript.js:


< script type =" text / javascript">

<! - //

document.write(''< s' '+''cript type =" text / javascript"

src =" javascript.php">< / s''+''cript>'');

// - >

< / script>


javascript.php:


<?php

session_start();

$ _SESSION [''javascript''] =''启用'';

? >


我可以看到javascript.js和javascipt.php文件都是从web日志执行的
,但当我尝试查询时
来自anot的
$ _SESSION [''javascript'']变量她的页面$ _SESSION是空的。


是否可以使用Javascript创建/更新Php会话?


可能使用URLEncoded完成URL,Javascript XMLHttpRequest,或者

之类的东西?

感谢您的帮助。


尊重,

加里

I am trying to create/update a Php Session with Javascript to confirm
if users have Javascript enabled.

My first thought was to create a Javascript that writes a script tag
referencing a php page, which sets a $_SESSION variable.

javascript.js:

<script type="text/javascript">
<!--//
document.write(''<s''+''cript type="text/javascript"
src="javascript.php"></s''+''cript>'');
//-->
</script>

javascript.php:

<?php
session_start();
$_SESSION[''javascript''] = ''enabled'';
?>

I can see that both the javascript.js and javascipt.php files are
executing from the web logs, but when I try to query the
$_SESSION[''javascript''] variable from another page $_SESSION is empty.

Is it possible to create/update a Php Session with Javascript?

Might it be done using URLEncoded URL, Javascript XMLHttpRequest, or
something of the like?

Thank you for your assitance.

Respectfully,
Gary

推荐答案

_SESSION变量。


javascript.js:


< script type =" text / javascript">

<! - //

document.write(''< s''+''cript type =" text / javascript"

src =" javascript.php">< / s''+ ''cript>'');

// - >

< / script>


javascript.php :


<?php

session_start();
_SESSION variable.

javascript.js:

<script type="text/javascript">
<!--//
document.write(''<s''+''cript type="text/javascript"
src="javascript.php"></s''+''cript>'');
//-->
</script>

javascript.php:

<?php
session_start();


_SESSION [''javascript' '] =''启用'';

?>


我可以看到javascript.js和javascipt.php文件是从web日志执行的
,但是当我尝试查询
_SESSION[''javascript''] = ''enabled'';
?>

I can see that both the javascript.js and javascipt.php files are
executing from the web logs, but when I try to query the


_SESSION [''javascript'']时来自另一页的变量
_SESSION[''javascript''] variable from another page


这篇关于使用Javascript创建/更新Php会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆