Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Reading PHP session variables with Classic ASP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Reading PHP session variables with Classic ASP

 Post Reply Post Reply
Author
ppowell777 View Drop Down
Newbie
Newbie


Joined: 02 July 2024
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote ppowell777 Quote  Post ReplyReply Direct Link To This Post Topic: Reading PHP session variables with Classic ASP
    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

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.