• Resolved Doodlebee

    (@doodlebee)


    I need to put something in my WordPress header to look for a cookie that may be set from another section of the site (a shopping cart). I don’t want WordPress to set the cookie – I just want it to *keep* the cookie if one has been set.

    So if someone goes to the blog, then goes to the shopping cart, the cart sets a cookie. I would like for wordpress to look for, and keep, that cookie if the user returns to the blog.

    Would anyone know the proper code to do that? I keep thinking it’s something like

    <?php if isset shopping cart cookie {
    keep cookie
    }?>

    Something simple like that. I also know this code has to be somewhere in the header – *before* anything else is processed. I need to figure out if I should put it in the wp-blog-header.php file, or if I just put it in the wp-content/themes/THEME/header.php file.

    If anyone has any ideas, that’d be great (I’m having a brainfart day – I *so* used to know how to do this, and the stuff I Google for is over my head for some reason. I think it’s because tomorrow’s my birthday, and my brain cells just want to die as fast as they can, because I’ll be officially old!)

    Thanks for any pity…I mean help…anyone can offer. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • WordPress doesn’t “keep” cookies… Your visitor’s browser does. WP can set them, read them or delete them. Shopping carts usually set temporary (per session) cookies, that expire as soon as the browser is closed. If you want to keep that type of cookie, check your cart’s documentation.

    Thread Starter Doodlebee

    (@doodlebee)

    Thanks. Actually, I *do* know that WordPress doesn’t “keep” cookies – apologies for my creative wording.

    I know that you can use PHP to recognize a cookie if it’s set, and “carry it” through a site you’re on. I also know you have to place it before anything else that appears on the page. My problem is, I haven’t done this in such a long time, I can’t quite remember *how* to do it.

    My question regarding WordPress is if I should place the code in the wp-blog-header.php file, or the theme/header.php file. I *think* it’s the latter, but I wasn’t sure.

    And I’m not worried about the browser closing, what I’m worried about is someone shopping, then moving to the blog temporarily. People will lose the items in their cart if they do that, and aren’t logged in.

    The thing about cookies is that they are written to your hard drive and don’t need to be passed around websites to be kept alive.

    It sounds like the problem lies somewhere within the shopping cart. Maybe it resets the cookies every time an unregistered/unlogged in customer visits the site. Do you have it check for an existing unregistered persons cookie before setting it?

    Thread Starter Doodlebee

    (@doodlebee)

    No, I don’t. Hmm..interesting. I’m going to look into this a bit and come back with my findings.

    For the record, the shopping cart I’m using is ZenCart. I’ve also posted on their forums as well (over a week ago) and haven’t had a response yet.

    Anyway, I’ll check again over there, and I’ll post back…

    Thread Starter Doodlebee

    (@doodlebee)

    Okay – I got it.

    It has *nothing* to do with anything I thought it did. I could just say “nevermind, I got it” and end it that way, but I *hate* doing that with forum threads. Even if I’m the only person who *ever* has this question – I feel I should say what my discovery is. So I will.

    ZenCart has a timeout set for the session. It’s 24 minutes. I can go to and from the cart as much as I like, just as long as I return in that 24 minute window, and I won’t lose a thing.

    So I don’t have to worry about carrying a cookie or anything – my bad! Sorry for the totally unrelated-to-WordPress question. (I swear, I thought it *could* have something to do with it, otherwise I never would have asked it here.)

    Your problem was solved, that’s what counts :p

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Look for cookies?’ is closed to new replies.