Results 1 to 4 of 4

Thread: Saving php objects in cookies

  1. #1
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default Saving php objects in cookies

    I am trying to save an object to a cookie, but its giving me the following error

    Fatal error: Call to a member function view() on a non-object in D:\__APACHE\test.php on line 70

    http://pastebin.com/338595


    Any ideas?

  2. #2
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    solution found:

    http://pastebin.com/338605

    i had to strip slashes from the cookie content.

  3. #3
    Join Date
    Oct 2004
    Posts
    4,814
    Rep Power
    24

    Default

    question?

    if(setcookie("saved_cart", serialize($shopping), time() + 3600, "/" ))

    why do they always set a cookie for the root of the site "/" thats pretty annoying!! . In this case I thing its valid but everysite I use always set cookies for their root. causing the cookie to sent in every http request even when not needed. Is it just a lazy thing or is it a design feature? why not set cookies for uri that need the cookie?

    SideNote: I am no php or wed developer but I write network code that medel with HTTP and the cookie thing is a royal pain in the ***.

  4. #4
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    Quote Originally Posted by leoandru
    question?

    if(setcookie("saved_cart", serialize($shopping), time() + 3600, "/" ))

    why do they always set a cookie for the root of the site "/" thats pretty annoying!! . In this case I thing its valid but everysite I use always set cookies for their root. causing the cookie to sent in every http request even when not needed. Is it just a lazy thing or is it a design feature? why not set cookies for uri that need the cookie?

    SideNote: I am no php or wed developer but I write network code that medel with HTTP and the cookie thing is a royal pain in the ***.
    Its probably because thats how they learnt to do it in a tutorial somewhere. I put it in, especially during development because as I move scripts around the path changes and its just easier to leave at "/" and from I have seen most people who use cookies want it accessible from root anyway based on what they are doing with it.

Posting Permissions

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