[DGD] Http daemon

Wes Connell wes at brutality.org
Sat Jan 5 17:40:33 CET 2002


.oOo. Stephen Schmidt (schmidsj at union.edu) wrote:

> On Fri, 4 Jan 2002, Lord Lerkista wrote:
> > Anyone have a http daemon that can send it to me??
> 
> A related question: Does anyone have an http daemon that can
> set cookies? If you can set a cookie, then you can identify
> each http connection with a particular player - otherwise
> I don't see a reliable way to do that. I might be missing
> something. If not, though, I'd recommend that anyone who
> is coding an http daemon support cookies, or some other
> method of identifying the requesting player.

What I've done with my httpd code (and it might not be the best way to do it)
was to actually output some Javascript code that accesses the document object
normally. 

I actually got this Javascipt from some JS help page... author unknown.

<script language="JavaScript">
<!--

// Use this function to retrieve a cookie.
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
    if (dc.length > 0) {
    begin = dc.indexOf(cname);
        if (begin != -1) {
        begin += cname.length;
        end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));
        }
    }
return null;
}

// Use this function to save a cookie.
function setCookie(name, value) {
document.cookie = name + "=" + escape(value) + "; path=/";
}

// Use this function to delete a cookie.
function delCookie(name) {
document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}
//-->
</script>

I spit the Javascript out first then I call something like:

send_html_output("<script language="JavaScript">);
send_html_output("setCookie(\"ACCOUNTNAME\", account_name);");
send_html_output("setCookie(\"PASSWORD\", encrypted_password);");
send_html_output("</script>");

Then show other HTML stuff.

I haven't used this in any sort of production code so there may be serious 
flaws in the way I handle this. It worked for me though. :)

Good luck!

-- 
Wes!
wes at brutality.org
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list