TOPIC: Problem trying to get the web server auth running

Hi,
I have recently been using your product and think it is great. I am not new to PHP however have been really struggling to get the web server authentication to work. I have read the docs and while this subject is spoken about I just need some help to get it running.

I am authenticating all users via a MYSQL database login form and not via HTTP. I planned to use cURL to call lime survey. My code I have been using is below and it simply is not working. I think the issue I am having is passing the authenticated user.

Am I completely off the mark for this integration or is there something very minor I am missing?
The build I am using is the latest stable release 200 build number 130406