| Recommend this page to a friend! | 
| PHP HTTP protocol client | > | All threads | > | Problems with Saving and Restoring... | > | (Un) Subscribe thread alerts | 
| 
 | |||||||||||||||
| 1 - 10 | 11 - 15 | 
| 
  Chris - 2007-07-22 22:19:49 - In reply to message 10 from Manuel Lemos Well, that is kind of what I was asking for help with.  See, I run the login class function with one button on my test page, it returns the correct code from the server that says I am logged in, and I see in the response headers 4 cookies set to show I am logged in.  Then, immediately after I run the second class function to run an admin panel command and it will give me one of a few cookie errors depending on different settings I Have. First Error: Error: invalid cookie secure value type (b:0;) Here is an example code to what I have done, in the index.php file I have set the global variable: $site_cookies = ''; in my class file I have two functions, the first function is the login function, here is how I have it formulated ( I have left out the output code but this is how your class is being called ): GLOBAL $site_cookies; $url = 'https://'.$config['APIx_domain'].'/admin/index.asp'; $results = $APIx_processor->GetRequestArguments($url,$arguments); $arguments["RequestMethod"]="POST"; $arguments["PostValues"]=array( "txtusername"=>$config['User'], "txtpassword"=>$config['Pass'], "PageAction"=>"LOGIN" ); $results = $APIx_processor->Open($arguments); if($results==""){ $results=$APIx_processor->SendRequest($arguments); $APIx_processor->Close(); $APIx_processor->SaveCookies($site_cookies); } That will always return the correct code that I have logged into the admin panel just fine. Right after I get that response I run the other class function: $url = 'https://'.$config['APIx_domain'].'/admin/main.asp?EditorAction=CUSTOMPAGEEDITOR'; $results = $APIx_processor->GetRequestArguments($url,$arguments); $arguments["RequestMethod"]="POST"; $arguments["PostValues"]=array( "txtTitle"=>$title, "FormAction"=>"AddNewPage" ); $results = $APIx_processor->Open($arguments); if($results==""){ $results=$APIx_processor->RestoreCookies($site_cookies); $results=$APIx_processor->SendRequest($arguments); $APIx_processor->Close(); } now the only time the error changes is if I change what the global cookies variable is set as: $site_cookies = ''; : Error: invalid cookie secure value type (b:0;) $site_cookies[] = ''; : Error: invalid cookie domain value type (b:0;) if I set $site_cookies = array(); it will go through just fine without any errors on my end, but the second function fails on the server side by redirecting me to the login again, and in the headers your class sent to the form, the cookies are not there. I have tried to layout as best I can how I have formulated my calls to your class, maybe I am misunderstanding how to use your cookies save and return functions and where to place them. I do understand that if I wait longer then the set time of the cookie it would fail, but I can't even get your class to return the cookies to the server at all unless I run my second function, and at the top it runs the login function itself each time. Then it works just fine which is ok by me, all I am trying to bypass is having to require my script to issue a login each time I want to run one function and instead be able to emulate keeping the client browser open and using the admin panel like a normal user. I can build in checks to have it re-login if the cookies expire, I just need to get the problem of them not being sent first resolve :) Thanks again for your help with this issue, Let me know if you need more information from my end to help explain my problem better. --- Chris 
  Manuel Lemos - 2007-07-23 00:10:06 - In reply to message 11 from Chris Those invalid cookie errors are returned because you are forging invalid cookies. Please use only the values returned by the class. What you need to do to understand why the login is not working is to set the class debug variable to 1, see the values that are returned by the server in the Set-Cookie header, save the cookies and see if the values are still there, and then access the server with a new object and see if the original cookies are still being sent. If all this happens, the problem is not with the class. Otherwise, you need to tell me what is not working so I can advise. Maybe I can see it faster if you can put up a couple of scripts in a site that I can access and see what is coming and going to the server when you login for the first time, and then when you access it again with saved cookies. 
  Chris - 2007-07-23 13:37:56 - In reply to message 12 from Manuel Lemos Ok, I am able to get it to save the cookies correctly and pull the cookies backup in the second function.  The problem is, first your class is only saving the first cookie of 4. Second, for some reason the cookies being passed by the admin panel are passed out of date. Here is a copy of the header return from the admin panel I am trying to access. set-cookie: AdminPass=; expires=Fri, 28-Jul-2006 05:00:00 GMT; path=/ set-cookie: AdminUser=; expires=Fri, 28-Jul-2006 05:00:00 GMT; path=/ set-cookie: AdminRemember=; expires=Fri, 28-Jul-2006 05:00:00 GMT; path=/ set-cookie: ASPSESSIONIDCCCQSDTR=LFEJNKJBKAMHEALEBHMMBIEK; path=/ When I use the panel in FireFox and look at what cookies are being passed, the only cookie used the whole time is the last cookie. Which I would imagine is my unique session ID. They might have left the other cookies in there from past versions. I am not sure, but for some reason those first three cookies are set to expire in 2006. When I try and return your saved cookes the only one in the array is 0, when there should be 4 or 0-3. So you can probably guess the error I am getting now, which is: Error: invalid cookie expiry value type (s:19:"2006-07-28 05:00:00";) which should happen since that cookie is mad expired. The question I have is, once you get the script to save more the one cookie for me, how would I go about telling it to not save cookies that are set expired already? -- Chris 
  Manuel Lemos - 2007-07-23 17:00:43 - In reply to message 13 from Chris The server sets the cookies with expired dates intentionally to make the browsers not send them again. The class was saving expired cookies inadvertently but that is an harmless problem because expired cookies are not sent to the server. The cookie expiry date validation bug was fixed last week. If you get notifications about changes to packages that you downloaded, you should have received an alert when the fixed version was uploaded. Anyway, just download the current version now. It also includes a fix to not save expired cookies. 
  Chris - 2007-07-23 17:52:47 - In reply to message 14 from Manuel Lemos That was it :)  works like a charm now.  Thanks so much for your help. and thanks again for such a great usable class. --- Chris | 
| 1 - 10 | 11 - 15 | 
info at phpclasses dot org.
