Communication between PHP and ASP

Hello Fellow Experts:

Im looking for a solution that will give me some sort of communication between PHP and C# ASP.NET (cookies?). I have users which will log into our website and authenticate via forms, with an active directory user account. From within the C# ASP site, users will click on a hyperlink, and I need to redirect the user to a PHP site on our linux server running apache. I'd like some way to pass the current username/password used to authenticate the users on the ASP site to the PHP site. The username/passwords will be the same. The only thing I can think of is by using cookies, or possibly writing to some external file on the client side, and then reading it via PHP. But will PHP read ASP cookies?

I cannot migrate the PHP content from linux to the windows server, this is not an option. I need a solution for my existing layout. Thanks!
kristenhazardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

maXXXeECommented:
Yes u can use cookies to do it.
but, there r other ways too, like using web services.
u can just call the web service method via php to authenticate the user, and u can set the wenservice to return the username,password, and result of authentication.
0
COBOLdinosaurCommented:
It has nothing to do with whether ASP and PHP can read each other cookies.  IT is not going to work becaue you have two different domains. A page from one domain cannot access the cookie created by a page from another domain. It is a security limitation and it makes cookies anon-starter for this.

Cd&
0
Tacobell777Commented:
You could probaby have the two to exchange data via WDDX have a look at openwddx.org
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

kristenhazardAuthor Commented:
maXXXeE:
Can you elaborate on how i can use web services and wenservice? I need a seamless transition from one platform to the other, w/o having the user re-type in his/her username/password. Possibly some code or examples to lead me in the right direction? Or maybe cookies will work?

Cd&:
The hosts will be different, but the domains will be the same, is that what you meant by two different domains?

Thanks.
0
kristenhazardAuthor Commented:
Tacobell777
Ill check it out.
0
maXXXeECommented:
wenservice->sorry, that was a typo ,it was webservice
0
maXXXeECommented:
if u want the basics, u can get all the info from here:
http://www.w3.org/2002/ws/
0
maXXXeECommented:
here u can find info on implementing webservices in asp.net
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconbuildingaspnetwebservices.asp

i havnt worked with web services on php, but i guess will get some help in the below link
http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html
0
COBOLdinosaurCommented:
Okay, two different boxes on the same domain should be okay.  I thought you were tyring to go cross-domain.

Cd&
0
kristenhazardAuthor Commented:
Cookies sound the easiest at this point, but the cookie from C# is not being read by PHP.

I tried setting the cookies in c# two ways, both failed
      Response.Cookies["username"].Value = this.login_username.Text;
      Response.Cookies["password"].Value = this.login_password.Text;

And I try to read the cookies in php like so:
      $username = $_COOKIE['smp_username'];
      $password = $_COOKIE['smp_password'];

Suggestions?
0
kristenhazardAuthor Commented:
the second way i tried to set the cookies in C#:

HttpCookie smp_username = new HttpCookie("smp_username", this.login_username.Text);
HttpCookie smp_password = new HttpCookie("smp_password", this.login_password.Text);
Response.Cookies.Add(smp_username);
Response.Cookies.Add(smp_password);

And i shouldnt say they failed, just failed to be read by PHP.
0
COBOLdinosaurCommented:
Are you getting an error message or is the code just being ignored?

Cd&
0
kristenhazardAuthor Commented:
Im not getting any errors, im pulling blank strings:

      $username = $_COOKIE['username'];
      $password = $_COOKIE['password'];

?>
<SCRIPT language="javascript">

alert( "username: <?echo $username;?> password: <?echo $password;?>" );

</SCRIPT>
<?php

this snippit returns blanks for my variables.
0
kristenhazardAuthor Commented:
I wanted to verify that asp was writing the cookie, so I go to FireFox, options, view cookies, and I dont see the two cookies im trying to write?! Any suggestions?
0
kristenhazardAuthor Commented:
I did some debugging, I watched the cookie get created and assigned the correct values, but I still dont know where the cookie is going on my local (client) computer. I checked out the cookies location, and I dont see the cookies. Ive also tried using this function, to give an expiration date to ensure persistance.

            private bool SetCookie(string cookiename, string cookievalue ,int iDaysToExpire)
            {
                  try
                  {
                        HttpCookie objCookie = new HttpCookie(cookiename);
                        Response.Cookies.Clear();
                        Response.Cookies.Add(objCookie);
                        objCookie.Values.Add(cookiename,cookievalue);
                        DateTime dtExpiry = DateTime.Now.AddDays(iDaysToExpire);
                        Response.Cookies[cookiename].Expires =dtExpiry;
                  }
                  catch( Exception e)
                  {
                        return false;
                  }
                  return true;
            }
0
kristenhazardAuthor Commented:
ok, another update. I've confirmed that the cookies are being created and are persistant. The function ive used to create the cookie follows:

private bool SetCookie(string cookiename, string cookievalue ,int iDaysToExpire)
{
      try
      {
            HttpCookie objCookie = new HttpCookie(cookiename, cookievalue);
            Response.Cookies.Add(objCookie);
            DateTime dtExpiry = DateTime.Now.AddDays(iDaysToExpire);
            objCookie.Expires =dtExpiry;
            Response.Cookies.Add(objCookie);
      }
      catch( Exception e)
      {
            return false;
      }
      return true;
}

But my problem still remains that PHP isnt reading the cookies. Help?
0
COBOLdinosaurCommented:
I don't know PHP so at this point I can' be much help; I'm afraid.

Cd&
0
kristenhazardAuthor Commented:
I think the problem is that cookies generated via c# asp are named differently that when generated via php. They are both put in the same folder, \Documents and Settings\user\Local Settings\Temporary Internet Files. How can I get php to read a manual filename/filepath for a cookie, or get c# to write to a manual filename/filepath that is standard to php?

c# asp generated cookiename:
Cookie:localusername@host.domainname.com/

php generated cookiename:
folder_path/

to clarify the php cookiename, a cookie is given the name folder_path/ from a site like so, www.domain.com/folder_path/ 

Someone throw me a bone ;)
0
kristenhazardAuthor Commented:
ive given up on cookies and solved this another way, for sake of posting this is what ive done.

Durring authentication against the AD, in c# I stored two session variables, first in clear text the username, the other was a md5 hash of the password. Then on the link that would be taking the users to the PHP site, I passed a username and hashed pw via $_GET and rewrote my authentication method on the PHP side to check if the md5 hash matched the SQL stored md5 password.

Moderator can you please close this, and thanks for guys for your posts and effort.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.