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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts

    cookie problem !

    Hi guys i dont know why but i found a problem at my webpage a few minutes ago. When i log in it do not create a cookies. i was trying to found the broken code because i didnt have idea where could be a problem... i deleted all from the login script file and in file is now just:

    setcookie("web_user", "failure");

    and it do now create a cookie!!! but when i try:

    setcookie("web_user", "failu re");

    it works... so my question ... WTF??? :P

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You're setting a cookie without an expire date,
    so I think it expires when the browser closes,
    much like SESSION. Try giving it an expiration date
    and I bet it will work for you ...

    setcookie("web_user", "failure", time()+604800); // one week

    Also, you can't set a cookie and read it in the same
    script without at least one page refresh. It's the
    page loading that sets the cookie (with the HTTP request header).


    .

  • #3
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    You're setting a cookie without an expire date,
    so I think it expires when the browser closes,
    much like SESSION. Try giving it an expiration date
    and I bet it will work for you ...

    setcookie("web_user", "failure", time()+604800); // one week

    Also, you can't set a cookie and read it in the same
    script without at least one page refresh. It's the
    page loading that sets the cookie (with the HTTP request header).


    .
    no i had it there i just removed because i wanted extremly easy for find a error.

    Hm... yea i know that i have to refresh page ... but i have following login:

    (take nick, pass, check db if exists ( everything working well ok ) and then:

    if is match in DB

    setting session
    update something in DB
    setcookie

    then i refresh a page ... session and db is updated but cookie is not set up

  • #4
    Regular Coder
    Join Date
    Jan 2012
    Location
    Slovakia
    Posts
    111
    Thanks
    9
    Thanked 0 Times in 0 Posts
    i have idea... could you recommend me some tool with which i check what is currently sending me in HTTP header to server or something like that. ? or something for scan php errors/blocks maybe something is blocking together.

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Post your exact code ... but X-out any passwords.
    The script where the cookie is set.


  •  

    Posting Permissions

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