1

Is there anyway to pass values from ASP.NET to PHP easily using Session or any other? I tried in the below way but it didn't work for me. Anybody either correct the below code or suggest me a way to pass values from ASP.NET to PHP without using URL query string.

ASP.NET code.

protected void Button1_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = new HttpCookie("myvalue1");
        cookie.Value = "joe@example.com";
        Response.Redirect("Default.php");
    }

PHP code.

<?php
session_start();
$_COOKIE['myvalue1'];
$cookies = getCookies();
$sessionId = $cookies['myvalue1'];
?>
Mad coder.
  • 2,175
  • 8
  • 38
  • 53

3 Answers3

2

You can create WSDL/REST API on the PHP side and simply send data from .Net to this API

1

There are a few ways to do this, but none are particularly sexy.

  1. Post the data from asp.net using an httpwebrequest to a php page, all done server side.
  2. A cookie with an encrypted value.
  3. If php and .net are both run on the same server, save to file system.
  4. A database server.
  5. ASP.NET supports multiple forms of persisting session state. State Server and Sql being 2 of them. I'm sure php could be configured to read them. You'd have to research how to do that. An article for sharing session between ASP.NET and classic ASP. Conceptually the same, and has the ASP.NET configuration part in the article. http://msdn.microsoft.com/en-us/library/aa479313.aspx

EDIT: You could even roll your own state server. Create a webservice that stores data from asp.net and php retrieves it when needed.

Darthg8r
  • 12,377
  • 15
  • 63
  • 100
  • Good answer! Seeking for syntax :( – Mad coder. Jan 13 '12 at 20:48
  • 1
    http://msdn.microsoft.com/en-us/library/debx8sh9.aspx Is an article on how to send data using httpwebrequest. You could retrieve the data posted and save to php session using normal get/post parameter handling in php. – Darthg8r Jan 13 '12 at 20:51
-2
Response.Redirect("Default.php?myparam=myvalue");
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92