Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - HttpAPI.asp Member Login from PHP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HttpAPI.asp Member Login from PHP

 Post Reply Post Reply
Author
deoiub View Drop Down
Newbie
Newbie


Joined: 09 February 2011
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote deoiub Quote  Post ReplyReply Direct Link To This Post Topic: HttpAPI.asp Member Login from PHP
    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)

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


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: 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 = "/" 
Back to Top
deoiub View Drop Down
Newbie
Newbie


Joined: 09 February 2011
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote deoiub Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
deoiub View Drop Down
Newbie
Newbie


Joined: 09 February 2011
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote deoiub Quote  Post ReplyReply Direct Link To This Post 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





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.