简体   繁体   English

ASP.NET/PHP:如何将会话变量从PHP传递到ASP.NET

[英]ASP.NET/PHP: How to pass session variable from PHP to ASP.NET

I was wondering if it's possible to pass a session coming from PHP by simply clicking a link from the PHP site 我想知道是否可以通过单击PHP站点上的链接来传递来自PHP的会话

from PHP site: 从PHP网站:

Click here 点击这里

and then the ASP.NET site (www.123company.com) will get the value of id=1 and use it to validate an existing function. 然后ASP.NET网站(www.123company.com)将获得id = 1的值,并使用它来验证现有功能。

Is it possible? 可能吗? Comments and suggestions are welcome. 欢迎提出意见和建议。 Thanks 谢谢

My guess is no. 我的猜测不是。 You will have to maintain session in DB and when you navigate to the ASP.net site, it should access the same db to retrieve the session. 您将必须在数据库中维护会话,并且当您导航到ASP.net站点时,它应该访问相同的数据库以检索会话。

Quick and dirty solution: 快速而肮脏的解决方案:

  • Create an .ASPX page which accepts parameters via the QueryString. 创建一个.ASPX页面,该页面通过QueryString接受参数。
  • Have your .ASPX page do some validation to check that it is your PHP script that is accessing it (ie not Joe Public on the internet). 让您的.ASPX页面进行一些验证,以检查是否是您的PHP脚本正在访问它(即,不是Internet上的Joe Public)。 Then have it set each of the QueryString parameters as session variables in the normal way. 然后以常规方式将每个QueryString参数设置为会话变量。
  • When you want your PHP page to be able to set a value in the ASP.NET session, fire off a simple HTTP request to your special ASPX 'bridging page'. 当您希望PHP页面能够在ASP.NET会话中设置值时,向您的特殊ASPX“桥接页面”触发一个简单的HTTP请求。 It will convert the querystring variables you've passed to it via the QueryString into Session values. 它将通过QueryString传递给它的querystring变量转换为Session值。

Providing the user maintains the current browser window, when navigating from your PHP script to your ASP.NET site, you should fine that does just the trick... 提供用户维护当前的浏览器窗口,从PHP脚本导航到ASP.NET站点时,您应该可以做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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