Print Page | Close Window

HttpAPI.asp Member Login from PHP

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=29118
Printed Date: 01 April 2026 at 4:04pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: HttpAPI.asp Member Login from PHP
Posted By: deoiub
Subject: HttpAPI.asp Member Login from PHP
Date Posted: 09 February 2011 at 5:24pm
I'm attempting to get the ability to sign members into my website with my own login procedures, and have them automatically logged into the forum on my site.

I'm trying to use the HTTPAPI method, because my site is written in PHP.  (documentation here:  http://demo.webwizforums.com/HttpAPI.asp#LoginMemberCookie" rel="nofollow - http://demo.webwizforums.com/HttpAPI.asp#LoginMemberCookie )

I'm able to use the API call fine to get back the response data in my PHP script, and I'm able to parse it into the various components.   However, I can't figure out how to set the cookie in PHP for the forum to recognize it.  PHP doesn't have native support for 'multi-value cookies' or 'cookie collections' that this seems to require, but as PHP is listed as one of the options that this is useful for, then I suspect I'm just missing something.

Any ideas how to use the CookieName, CookieKey, and CookieData to create and set the cookie in PHP for ASP to read it properly?

The 2 closest attempts I feel I've made so far, though neither are working are:

setcookie($cookiename, $cookiekey."=".$cookiedata, time()+7200, "/", ".domain.com");
setcookie($cookiename."[".$cookiekey."]", $cookiedata, time()+7200, "/", ".domain.com");

Any help here?

Thanks





Replies:
Posted By: WebWiz-Bruce
Date Posted: 09 February 2011 at 5:30pm
Not done much with cookies in PHP so can not say for sure, however, make sure you edit the includes/setup_options_inc.asp file and set the cookie path to the root of your website, otherwise the forum can not read in cookies set out side it's own directory:-

strCookiePath = "/" 


-------------
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


Posted By: deoiub
Date Posted: 09 February 2011 at 5:36pm
Thanks for that suggestion.

I've just toggled that, and it didn't solve my issue.  

When I use the code on the following page to display cookie values, my cookies that I set in PHP are showing up, but always in the 'single value cookies' list, where I suspect I need to set them so that they will show in in the multi-value list.  ( http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6539" rel="nofollow - http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6539 ) 


Posted By: deoiub
Date Posted: 10 February 2011 at 1:29pm
I finally solved this problem, and it was a separate issue than I initially thought.   

The problem was resulting from ASP and PHP using different encodings for cookies.

ASP encodes . and - (and likely other characters) in hex format, 

so the cookie with value: user.name-Z9D3-FC9-Z6A3-825C  

is actually stored in the cookie as:  user%2Ename%2DZ9D3%2DFC9%2DZ6A3%2D825C

PHP's function urlencode will convert most non A-Z0-9 characters to hex, but will leave . _ - untouched, so I had to write a function to convert those as well

Here is how I was able to get PHP to store the cookie in a format that the forum/ASP would pickup on and do the autologin with:

(after parsing the XML response from the API with action="LoginMemberCookie")

function asp_cookie_encode($string){
$new_string = urlencode($string);
$new_string = str_replace(".","%2E",$new_string);
$new_string = str_replace("-","%2D",$new_string);
$new_string = str_replace("_","%5F",$new_string);

return $new_string;
}

$cookievalue = $cookiekey."=".asp_cookie_encode($cookiedata);
setrawcookie($cookiename,$cookievalue,time()+7200,"/",".domain.com");

-----------

Hopefully this will be of some use to someone else in the future.

D








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