Results 1 to 2 of 2

Thread: cookies and vbscript

  1. #1

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    cookies and vbscript

    Guys

    I'm having trouble doing something as simple as setting and reading a cookie using vbscript.

    The issue is this. I need to set a cookie which holds a database connection string depending on whether the code is running on a local server or my live webserver. I currently do this without cookies by simply setting the value of a variable using asp and servervariables("HTTP_POST") however I now need to do this in vbscript (for reasons to long winded to go into).

    I have a link which calls a vbscript sub routine

    Code:
    <div id="QuoteButt"><a href="someurl" target="_blank" id="lnk" class="Link03">Click here</a></div>
    This calls the sub

    Code:
    <script language="VBScript">
    sub lnk_onclick()
    set oConn = CreateObject("ADODB.Connection")
    'now, here's the problem. I need to do something to determine what server I'm using. In asp I would do this:
    if request.servervariables("HTTP_HOST") = "localhost" Then
    strConnex = "Provider=sqloledb;SERVER=localserver,UID=myuid;PWD=mypwd;DATABASE=mydatabase"
    else
    strConnex = "Provider=sqloledb;SERVER=liveserver,UID=myuid;PWD=mypwd;DATABASE=mydatabase"
    end if
    'do some other stuff
    end sub
    </script>
    Now, I can set this string in asp and store it in a variable however when I try to read it in vbscript, it's empty. I can store it in a cookie and I can read it by using

    Code:
    'asp
    
    response.cookies("connex") = strConnex
    
    'vbscript
    alert document.cookie
    But this gives me every cookie stored for the session, which isn't good (also, it's html encoded which doesn't help).

    I just want to be able to read the connection string cookie using vbscript and use this to open my database conneciton! It aint rocket science. Is it?!

    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  2. #2

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    Re: cookies and vbscript

    Sorted this but I have another problem. I'm getting this error:

    safety settings on this computer prohibit accessing a datasource on another domain.

    I obviously can't just change the browser settings as this won't be any help to my users. Is there something I can do in IIS (v5)?
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width