mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Can be used to insert a new response into a questionnaire via XML-RPC Added xmlrpc package from: http://phpxmlrpc.sourceforge.net (new BSD licence compatible with GPL)
14 lines
5.9 KiB
HTML
14 lines
5.9 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Does the library support using cookies / http sessions?</title><link rel="stylesheet" href="xmlrpc.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.74.3" /><link rel="home" href="index.html" title="XML-RPC for PHP" /><link rel="up" href="ch12.html" title="Chapter 12. Frequently Asked Questions" /><link rel="prev" href="ch12s08.html" title="Can I use the ms windows character set?" /><link rel="next" href="apa.html" title="Appendix A. Integration with the PHP xmlrpc extension" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Does the library support using cookies / http sessions?</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch12s08.html">Prev</a> </td><th width="60%" align="center">Chapter 12. Frequently Asked Questions</th><td width="20%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr></table><hr /></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="id539485"></a>Does the library support using cookies / http sessions?</h2></div></div></div><p>In short: yes, but a little coding is needed to make it
|
||
happen.</p><p>The code below uses sessions to e.g. let the client store a value
|
||
on the server and retrieve it later.</p><pre class="programlisting"><code><span style="color: #000000">
|
||
<span style="color: #0000BB">$resp </span><span style="color: #007700">= </span><span style="color: #0000BB">$client</span><span style="color: #007700">-></span><span style="color: #0000BB">send</span><span style="color: #007700">(new </span><span style="color: #0000BB">xmlrpcmsg</span><span style="color: #007700">(</span><span style="color: #DD0000">'registervalue'</span><span style="color: #007700">, array(new </span><span style="color: #0000BB">xmlrpcval</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">), new </span><span style="color: #0000BB">xmlrpcval</span><span style="color: #007700">(</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">))));<br />if (!</span><span style="color: #0000BB">$resp</span><span style="color: #007700">-></span><span style="color: #0000BB">faultCode</span><span style="color: #007700">())<br />{<br /> </span><span style="color: #0000BB">$cookies </span><span style="color: #007700">= </span><span style="color: #0000BB">$resp</span><span style="color: #007700">-></span><span style="color: #0000BB">cookies</span><span style="color: #007700">();<br /> if (</span><span style="color: #0000BB">array_key_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHPSESSID'</span><span style="color: #007700">, </span><span style="color: #0000BB">$cookies</span><span style="color: #007700">)) </span><span style="color: #FF8000">// nb: make sure to use the correct session cookie name<br /> </span><span style="color: #007700">{<br /> </span><span style="color: #0000BB">$session_id </span><span style="color: #007700">= </span><span style="color: #0000BB">$cookies</span><span style="color: #007700">[</span><span style="color: #DD0000">'PHPSESSID'</span><span style="color: #007700">][</span><span style="color: #DD0000">'value'</span><span style="color: #007700">];<br /><br /> </span><span style="color: #FF8000">// do some other stuff here...<br /><br /> </span><span style="color: #0000BB">$client</span><span style="color: #007700">-></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">'PHPSESSID'</span><span style="color: #007700">, </span><span style="color: #0000BB">$session_id</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">$client</span><span style="color: #007700">-></span><span style="color: #0000BB">send</span><span style="color: #007700">(new </span><span style="color: #0000BB">xmlrpcmsg</span><span style="color: #007700">(</span><span style="color: #DD0000">'getvalue'</span><span style="color: #007700">, array(new </span><span style="color: #0000BB">xmlrpcval</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">)));<br /> }<br />}</span>
|
||
</span>
|
||
</code></pre><p>Server-side sessions are handled normally like in any other
|
||
php application. Please see the php manual for more information about
|
||
sessions.</p><p>NB: unlike web browsers, not all xmlrpc clients support usage of
|
||
http cookies. If you have troubles with sessions and control only the
|
||
server side of the communication, please check with the makers of the
|
||
xmlrpc client in use.</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch12s08.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch12.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Can I use the ms windows character set? </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix A. Integration with the PHP xmlrpc extension</td></tr></table></div></body></html>
|