Thread: Cookies..

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    142
    Rep Power
    15

    Cookies..


    How to tell if one is defined or not.. ?
    i tried
    <cfif #cookie.x# is ''>
    but no go.. how would you do that?

    Also i have a field in my database that has numbers in it like: 43,35

    how could i take one of the numbers and set it as a cookie, and put the other as another?
    ie: #cookie.x# as 43, and #cookie.y# as 35..
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,307
    Rep Power
    972
    <cfif not structKeyExists( cookie, 'myKey' )>
    <cfset cookie.myKey = "whatever">
    </cfif>
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    142
    Rep Power
    15

    Thanks


    Originally Posted by kiteless
    <cfif not structKeyExists( cookie, 'myKey' )>
    <cfset cookie.myKey = "whatever">
    </cfif>
    How am I going to have to do the last part of it? Or should I just use two different fields for the two?
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,307
    Rep Power
    972
    Yes just set two cookie values. cookie.a = "blah" cookie.b = "foo"

    Remember that there are limits to how many cookies you can store as well as the size of the cookies. Don't rely on cookies to store many values or any values of large size.
  8. #5
  9. Wickedwd.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Location
    wickedwd.com
    Posts
    201
    Rep Power
    0
    I honestly didnt read the whole thread so if this makes no sence "my bad"

    Code:
    <CFIF IsDefined("COOKIE.mycookie")
    do whatever
    </CFIF>
    
    the opposite also works
    
    <CFIF not IsDefined("COOKIE.mycookie")
    do whatever
    </CFIF>
    -Alas
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    142
    Rep Power
    15
    Ok i'm new.. so please someone tell me why this isn't working.

    <CFIF NOT structKeyExists(cookie, "x")>
    <cfquery name="get_x" datasource="aeris7282">
    Select x from map
    where user_id = '#session.user_ID#'
    </cfquery>
    <cfoutput query="get_x>
    <cfcookie name="x" value="#x#">
    </cfoutput>
    </CFIF>
  12. #7
  13. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,307
    Rep Power
    972
    Post the error. The code doesn't help at all if you don't explain what is happening.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    142
    Rep Power
    15
    There isnt one. Just nothing is happening..

    Originally Posted by kiteless
    Post the error. The code doesn't help at all if you don't explain what is happening.
  16. #9
  17. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,307
    Rep Power
    972
    You might try:

    <CFIF NOT isDefined( 'cookie.x' )>
    ...
    </cfif>


    Can't remember, but cookie might not be treated as a struct.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    142
    Rep Power
    15
    oh wow im embaressed, i forgot an end quote.

    Originally Posted by kiteless
    You might try:

    <CFIF NOT isDefined( 'cookie.x' )>
    ...
    </cfif>


    Can't remember, but cookie might not be treated as a struct.

IMN logo majestic logo threadwatch logo seochat tools logo