Perhaps I'm mis-reading your question, but it seems like what you're looking to do is save some options or info from your widget (username and password) somewhere in WordPress where you can then re-access them outside the widget code. If that's correct, you'll want to look at the add_option() function (as well as update_option() and delete_option() as necessary).

To set an option, just do this:

<?php add_option("my_widget_option_name", 'option_value'); ?>

You can then retrieve it anywhere within WP by calling get_option like this:

Can you explain a little more what it is you're trying to do? Is the idea to set the username and password for the service in a widget form and then to pass those along to the service on every page load to deliver some content to the website user (without displaying the username and password)?
–
brandwaffleSep 23 '10 at 10:11

Ok thanks, will give it a try. I am muddling along at the moment, partly due to time pressure.
–
JohnnyBizzleSep 23 '10 at 12:47

To explain further, the widget posts 2 options, Service required and Postal Code. The form submits to a specific page (I know I could use the current page) which I have called search-results. Search results takes the options which I pass into the url calling the webservice. The results come back as XML which gets passed into an array and then output to the user. This site is using the same webservice: camden.nhs.uk/nhs-search-results.htm?type=1&q=E17
–
JohnnyBizzleSep 23 '10 at 12:51

...the intention was to use parameters for the username/pwd for the webservice so that other sites could use the same widget.
–
JohnnyBizzleSep 23 '10 at 13:03

Ok, so site owners will need to input their own username and password, correct? Once they do that, it uses that info to pull the XML from the other site and then display it. In that case, you do want to use get_option and add_option. The apply_filters function works on the display side of things--i.e. it does not change data in your database, it modifies it before it is displayed to the end user. It sounds like you want to take in the form input in the widget and save it with add_option. This site has a great tutorial: valums.com/create-wordpress-widget
–
brandwaffleSep 23 '10 at 15:33