Print Page | Close Window

Reading PHP session variables with Classic ASP

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=31802
Printed Date: 28 March 2026 at 8:41am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Reading PHP session variables with Classic ASP
Posted By: ppowell777
Subject: Reading PHP session variables with Classic ASP
Date Posted: 02 July 2024 at 5:18pm
Is it possible to read a session variable set by a separate PHP file using Classic ASP?

I have these files:

/index/blah.asp:
```

<%@ language = "Javascript" %>

<!-- #include file="globals/prototypes.asp" -->

<!-- #include file="includes/blah.asp" -->

```
/includes/blah.asp:
```

<%

var obj = Server.CreateObject("MSXML2.ServerXMLHTTP");

obj.open("GET", "http://localhost/index/includes/blah.php", false);

obj.send();

Response.Write(obj.responseText);

for (var i in Session.Contents) {

   Response.Write("Session.Contents(\"" + i + "\") = " + Session.Contents(i) + "<BR /><BR />");

}

%>

```

/includes/blah.php:
```

<?php

$str = 'Hello World';

echo '$str = ' . $str . "<Br /><BR />";

$_SESSION['helloworld'] = $str;

?>

```
The reason for this is to prevent having to change an entire section of a website from ASP to PHP, thus, altering the forward-facing URL which currently ends in "*.asp" and has done for years, but the means of dynamically populating its content could possibly be changed from ASP to PHP, using session variables to pass back and forth.

If not possible, then everything will remain in Classic ASP and I'll call it a day, but at least I figured I would ask in case I missed something.

Thanks




Replies:
Posted By: WebWiz-Bruce
Date Posted: 02 July 2024 at 6:06pm
When I have needed ASP and PHP to talk to each other in the past I have built an API to handle the communication between the two.

If the PHP files are in a folder with no ASP files you could add a web.config file to the folder with a handler that sets *.asp files to be handled by PHP instead of ASP, so you can continue using the .asp extension, but with your PHP files.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net