Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts

    Question regarding cookies please.

    ow does the code get the visitor's name? Say you [John Doe] visited my website and I wish to place a cookie on your pc if you don't have to fill out a form on my site then how will I know what your name is to place in the setcookie function?

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,530
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Unless the user provides you some sort of data about who they specifically are, you can't store it. By visiting your site, the user gives you data like IP, browser, and OS... but that's obviously not what you're looking for. Unless they have some some technique of identifying themselves, such as a login, an already existent cookie you have access to, etc, you can't know who they are.

  • Users who have thanked Keleth for this post:

    mikehende (05-26-2011)

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts
    So to clarify, cookies only works if the you have some user form or login? is this correct?

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    You will need a form yes. Initially you'll have to ask the user their name. There is no way to 'just know it'.

    Once you have their name remember to set the cookie before any html or whitespace is output. Cookies are set in the http headers so you must do this before ANYTHING goes to the browser.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    mikehende (05-26-2011)


  •  

    Posting Permissions

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