Ever tried to set cookie expiry date using JavaScript?

Discussion in 'ASP General' started by Vince C., Oct 5, 2003.

  1. Vince C.

    Vince C. Guest

    Hi all.

    I'm trying to set a cookie expiry date but my script is JS (JavaScript). I've
    tried

    Response.Cookies("Test").Expires = Date();
    Response.Cookies("Test").Expires = Date().toLocaleString();
    Response.Cookies("Test").Expires = Date().toString();
    Response.Cookies("Test").Expires = Date().toUTCString();

    none works. I've seen what bothers IIS is the day name when assigning the expiry
    date: "7 février 2004 11:57:57" is ok while "samedi 7 février 2004 11:57:57"
    produces an error "Invalid type".

    Ok, I could switch to VB Script (which I think I'll do because of the ease of
    doing it in that language). But I'd like to know if there are well-known tricks
    on using IIS/ASP and cookies expiry date in JavaScript. It seems IIS object
    model is unable to recognize (or handle) JavaScript dates...

    Might sound a stupid question but I'd like my script to be as platform
    independent as possible. Why? I'm running a French version of Windows 2000/IIS5.
    I might have to host my web on an English version. Or whatsoever. I wouldn't
    like to triturate the date string for it depends on the current locale. If
    JavaScript cannot be used without modifying the string I'll switch to VB script.

    Thanks for any hint or suggestion.

    Vince C.
    Vince C., Oct 5, 2003
    #1
    1. Advertising

  2. Vince C.

    MSFT Guest

    Hi Vince,

    Based on my experience, we may use JavaScript and Date function to set
    cookies on client side, for example:

    http://www.webreference.com/javascript/961125/source.html

    On server side, we can convert the date to a string like "mm/dd/yyyy" or
    use VB script instead.

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    MSFT, Oct 6, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. beji
    Replies:
    0
    Views:
    367
  2. Milsnips
    Replies:
    1
    Views:
    415
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 15, 2007
  3. Ray

    cookie expiry date problem

    Ray, Apr 21, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    149
  4. Guest

    Read cookie expiry date?

    Guest, Aug 7, 2004, in forum: ASP General
    Replies:
    1
    Views:
    218
    Dave Anderson
    Aug 8, 2004
  5. Replies:
    4
    Views:
    127
    Dr John Stockton
    Jul 30, 2005
Loading...

Share This Page