打开PHP页面/同时初始化会话变量?

时间:2022-09-20 12:22:50

I'm pretty new to PHP and JSON/XML, but we're forging ahead.

我是PHP和JSON / XML的新手,但我们正在向前迈进。

Our project entails logging in to a webservice (which we also built) from a handheld device and then accessing our website from that device. The point is to only allow users who have logged in on the handheld device to access the webpage.

我们的项目需要从手持设备登录Web服务(我们也构建),然后从该设备访问我们的网站。关键是只允许已登录手持设备的用户访问该网页。

Now, I guess this doesn't only apply to handhelds, but here's the question:

现在,我想这不仅适用于掌上电脑,但问题是:

We can send an HTTPRequest from the handheld device and use a PHP script to validate login info from a database, and then return either a 'success' or 'failure' JSON object. If the user succeeds in logging in, our webservice will be opened in a browser window.

我们可以从手持设备发送HTTPRequest并使用PHP脚本验证来自数据库的登录信息,然后返回“成功”或“失败”JSON对象。如果用户成功登录,我们的Web服务将在浏览器窗口中打开。

The online application relies on Session Variables for authentication every step of the way. Is there some way we can send the HTTPRequest, receive authentication, and then somehow feed the very same page we are opening some data which it will parse into session variables?

在线应用程序依赖会话变量进行身份验证的每一步。有没有什么方法可以发送HTTPRequest,接收身份验证,然后以某种方式提供相同的页面,我们打开一些数据,它将解析为会话变量?

1 个解决方案

#1


1  

It depends on the device. Some mobile phones (like flip phones for example) will most likely not have support for AJAX. Smartphones, on the other hand, will most likely have support for AJAX.

这取决于设备。一些手机(例如翻盖手机)很可能不支持AJAX。另一方面,智能手机很可能会支持AJAX。

To make it compatible with all devices, your best bet is sticking with a standard login system that posts the variables to the same page or another page for validation. Otherwise, you will be making several different websites to work on various phones.

为了使其与所有设备兼容,最好的办法是坚持使用标准登录系统将变量发布到同一页面或其他页面进行验证。否则,您将制作几个不同的网站,以便在各种手机上工作。

#1


1  

It depends on the device. Some mobile phones (like flip phones for example) will most likely not have support for AJAX. Smartphones, on the other hand, will most likely have support for AJAX.

这取决于设备。一些手机(例如翻盖手机)很可能不支持AJAX。另一方面,智能手机很可能会支持AJAX。

To make it compatible with all devices, your best bet is sticking with a standard login system that posts the variables to the same page or another page for validation. Otherwise, you will be making several different websites to work on various phones.

为了使其与所有设备兼容,最好的办法是坚持使用标准登录系统将变量发布到同一页面或其他页面进行验证。否则,您将制作几个不同的网站,以便在各种手机上工作。