Results 1 to 5 of 5

Thread: Cookies, PHP, and refreshing

  1. #1

    Thread Starter
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Cookies, PHP, and refreshing

    OK, I'm working on a modification to a webpage where I need to set cookies for a particular functionality. Having worked with cookies & PHP before, I know that the cookie value will not take until AFTER the page is refreshed. Since this cookie will be set on every page, I don't really want to refresh it everytime. So, I want to now if I jsut setCookie, then the user clicks a link, will that be sufficient, or do I really need to find a different way to do this? Secondly, if I setcookie, don't refresh, and then the user goes to a new website, sy by either a click to the new site, or by entering an address in the address bar, will the cookie remain intact (it's going to be a session variable, so I don't care once they close their browser.)?

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  2. #2

    Thread Starter
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    *bump-a-loompa*
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Cookies, PHP, and refreshing

    I'm pretty confused as to what you want. What data is being saved in the cookie? Is it login information (my best guess since you're resetting it everytime)?

    Originally posted by techgnome
    So, I want to now if I jsut setCookie, then the user clicks a link, will that be sufficient, or do I really need to find a different way to do this?
    What will the link go to? Will it just be a link to the current page (a way to refresh)? If so, yes.

    Originally posted by techgnome
    Secondly, if I setcookie, don't refresh, and then the user goes to a new website, sy by either a click to the new site, or by entering an address in the address bar, will the cookie remain intact (it's going to be a session variable, so I don't care once they close their browser.)?
    Cookies will stay for as long as you set them. The default expires when the browser window closes (not when they navigate away).

    I'm not sure if I'm helping you at all with any of this, since I'm still confused.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Hmmm...... how can I describe this....
    OK... let me try explaining it like this:

    User hits my site for the first time.
    I take the current URL and the page name (Home) and put them into an array.
    I then serialize the array and store it in a cookie.
    Somewhere later on the page, I'll use the array to show where on my site they've been (In this case it will simply list "Home" as a link.)
    Let's say they then click on a link that takes them into a postinc caregory, "Brewmeister".
    When the page loads, it finds the cookie, extracts it, and unserializes it into the array (which has the link and title to my "Home" page), and adds the new page to the array. The array should now contain two items, "Home" and "Brewimeister." I reserialize the array and stuff it back into the cookie.
    Again, later I'll use the array to shwo where the user was: "Home" -> "Brewmeister"
    As the user goes trapising through my site, I want to grab the cookie, unserialize the array, add to the array, then serialize the array back into the cookie.

    If it helps, there is also this post where I attempt to describe *** I am doing...
    http://wordpress.org/support/4/3424#post-5

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    Loading a new page that will open the cookie will suffice and count as a page refresh. If your user left your page and had "Home -> Brewmister" or whatever, and then came back and entered on the Home page, it would add to the array like "Home -> Brewmister -> Home".. if that's what you wanted, then what you're thinking of is totally possible and you're on your way to doing it.

    If you are wanting to also show the current page they are on, you can't do it with using ONLY cookies, but you can grab your "current page" variable and print it out along with the cookie.

    Also, the cookie will remain intact until it has met it's expiry date, whether it be a session cookie, where it expires when the user has their browser closed, or it's expiry is in 30 days.

    Hope that helps..
    Like Archer? Check out some Sterling Archer quotes.

Posting Permissions

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



Click Here to Expand Forum to Full Width