Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I need help with cookies and keys


I'm having trouble using a set of cookie keys

respond.cookies("user")("name")
respond.cookies("user")("email")

Now, I can get cookies to work in my page, its just when I add the keys that it screws up...is there a special way to access keys or can you make seperate cookies all together like this ==>

respond.cookies("user")
respond.cookies("email")

if anyone has any working code examples of successfully using cookies with keys...i'll be extremely grateful

Comments

  • bagles1bagles1 Posts: 54Member
    Maybe this will help, straight from Microsoft:

    Response.Cookies(cookie)[(key)|.attribute] = value

    cookie
    The name of the cookie.

    key
    An optional parameter. If key is specified, cookie is a dictionary, and key is set to value.

    attribute
    Specifies information about the cookie itself. The attribute parameter can be one of the following. Name Description

    Domain: Write-only. If specified, the cookie is sent only to requests to this domain.

    Expires: Write-only. The date on which the cookie expires. This date must be set in order for the cookie to be stored on the client's disk after the session ends. If this attribute is not set to a date beyond the current date, the cookie will expire when the session ends.

    HasKeys: Read-only. Specifies whether the cookie contains keys.

    Path: Write-only. If specified, the cookie is sent only to requests to this path. If this attribute is not set, the application path is used.

    Secure: Write-only. Specifies whether the cookie is secure.


    Value
    Specifies the value to assign to key or attribute.
    Remarks
    If a cookie with a key is created, as in the following script,

    <%
    Response.Cookies("mycookie")("type1") = "sugar"
    Response.Cookies("mycookie")("type2") = "ginger snap"
    %>

    this header is sent.

    Set-Cookie:MYCOOKIE=TYPE1=sugar&TYPE2=ginger+snap

    A subsequent assignment to myCookie without specifying a key, would destroy type1 and type2. This is shown in the following example.

    <% Response.Cookies("myCookie") = "chocolate chip" %>

    Hope this helps!

    -Bagles1


  • RajeshebRajesheb Posts: 2Member
    Just try the below code
    To Add cookie
    Response.Cookies("user")("name")="Name"
    To Get cookie
    Request.Cookies("user")("name")


    :
    : I'm having trouble using a set of cookie keys
    :
    : respond.cookies("user")("name")
    : respond.cookies("user")("email")
    :
    : Now, I can get cookies to work in my page, its just when I add the keys that it screws up...is there a special way to access keys or can you make seperate cookies all together like this ==>
    :
    : respond.cookies("user")
    : respond.cookies("email")
    :
    : if anyone has any working code examples of successfully using cookies with keys...i'll be extremely grateful
    :

Sign In or Register to comment.