Monday, December 12, 2005
I had a situation where I needed to use the Login Session of PHP to use in a ASP page. I went through Google for an hour; I couldn't find any solution regarding this. Then I decided to write my own module which can use the PHP's session in ASP.
Idea is simple; make a PHP page with a FORM and hide all the PHP session in that form as a hidden input type then create a button to submit to a ASP page which can read the Form variables and create new ASP session out of them, then you can use that ASP's session as long as you are in ASP pages Wink
Here is a Sample PHP & ASP session commands: PHP Page:
<? session_start(); header("Cache-control: private"); //IE 6 Fix $_SESSION["valid_id"] = 1; $_SESSION["valid_user"] = 1234; $_SESSION["valid_title"] = "Manager"; $_SESSION["valid_time"] = time(); $_SESSION["dep"] = "IT Dep"; $_SESSION["fname"] = "John"; $_SESSION["lname"] = "Doe"; ?> <form action="session.asp" method="post"> <input type="hidden" name="valid_user" value="<?=$_SESSION["valid_user"];?>"> <input type="hidden" name="valid_id" value="<?=$_SESSION["valid_id"];?>"> <input type="hidden" name="valid_title" value="<?=$_SESSION["valid_title"];?>"> <input type="hidden" name="dep" value="<?=$_SESSION["dep"];?>"> <input type="hidden" name="fname" value="<?=$_SESSION["fname"];?>"> <input type="hidden" name="lname" value="<?=$_SESSION["lname"];?>"> <input type="submit" name="submit" value="Open ASP Session"> </form>
ASP Page called "session.asp": <% Session("valid_user")=request.form("valid_user") Session("valid_id")=request.form("valid_id") Session("valid_title")=request.form("valid_title") Session("dep")=request.form("dep") Session("fname")=request.form("fname") Session("lname")=request.form("lname") response.write( Session.Contents("lname") & " " & Session.Contents("fname") ) 'Printing the results
%>
|
| To learn PHP Session please visit: www.php.net/session
To learn ASP Session please visit: http://www.w3schools.com/asp/asp_sessions.asp
I have attached a zip file with both scripts, please download and upload it in your server and run the "session.php"
http://www.spydb.com/files/session.zip
posted by
Ranch
at 8:20 AM
|