dtwzwmv87399 2011-03-07 14:30
浏览 48
已采纳

我可以登录ASP.NET(使用Forms身份验证),然后将“登录”传输到PHP应用程序吗?

Our website runs on ASP.NET v4 and users log in user Forms authentication.

We are considering purchasing a web application that will add to our services. The only problem is that this new website is written in PHP.

We would like users to login to our ASP.NET site and then navigate to the PHP site. The PHP site should notice that users are logged-in though. So we probably need to transfer the ASP.NET SessionID cookie and somehow use that to verify whether or not the user has been authorized.

Does this sound feasible? Or am I barking up the wrong tree?

  • 写回答

4条回答 默认 最新

  • dowb58485 2011-03-07 14:47
    关注

    It is surely possible, but you need some dirty-coding to do.

    In fact, both ASP.NET and PHP Sessions create a software layer that hides mechanisms used to perform session handling and validation.

    You can simply define a common cookie between the two applications (make sure you sign it or store it in a common DB), then use your own custom logic to link an ASP.NET session to PHP.

    Database is a great option. I would recommend you to define a custom session manager class in Web.config and have it write session data in common DB, from where PHP will load.

    But I don't know how to write a custom PHP session manager. You might consider using custom PHP code on page init to initialize session basing on data found on DB.

    So your application will be made of three things:

    • ASP.NET part
    • PHP part
    • Common database

    A simple usage scenario:

    1. User performs login on ASP.NET
    2. ASP.NET validates login, sets a cookie with known name and inserts a row in the database with cookie value (and possibly IP address for security)
    3. User navigates PHP site transmitting the cookie
    4. PHP checks cookie against table, and possibly initializes its own session

    More complex designs could actually share session data between both PHP and ASP.NET using a single database table AND no local memory.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)