I really hate cookies!

But how does the cookie know the session is over?

HalfaBee

    the cookie is a file
    it doesn't know anything.
    the client's browser, on the other hand, know when cookies expire and deletes them.
    a session is over when the browser closes.

    so by not specifiing an expire date for the cookie the cookie will last as long as the client's browser is opened.

      Yes I know that.
      But it still doesn't answer the question.

      What time is the cookie set to expire?

      You said it was when the session was over, but that could be 1 minute or 20 minutes.

      So what is the cookie expire time set to when you do not specify the expire time?

      HalfaBee

        I've reedited my post... I hope that will answer your question

          Originally posted by HalfaBee

          So what is the cookie expire time set to when you do not specify the expire time?

          Cookie will be active until client close browser window

            OK. Thanks for that.

            So if I set the time to expire for 2 seconds what happens?

            HalfaBee

              Thanks for that.

              The php manual I have on my PC did not say that 'if not set it lasts a session'

              Thanks for the help

              HalfaBee

                Hi

                Golly, I didn't expect that much interest 😃

                As to cosminb's suggestion to go to another file, my argument is that the user can then bookmark that page and thus avoid the check.

                My suggestion was for those who needed to keep the user in the index page without them knowing what variable had been used to test.

                Of course the cookie can be set to whatever expriy you want, this was JUST an example.

                I DID say, right at the outset, that it relied on java being enabled.

                But, most importantly, given my needs (and often the needs of other web writers), the method I posted still seems the only way to do it.

                1. NO re-direct to another page.
                2. No way to bookmark the page to avoid the check.
                3. Not looking for a particular cookie, just to check IF they are enabled.

                I have seen folks asking for such a method so many times.

                All of you have valid points, but does anyone have any alternative method that works to satisfy the 3 conditions?

                Trevor

                  Tip to avoid bookmark and skip the cookie test:
                  You can always check on startPage.php if
                  $SERVER['HTTP_REFERER'] is index.php.
                  I'm not checking for a particular cookie, I'm just too see if that cookie has a value. You can use
                  if ($
                  COOKIES)
                  instead of
                  if ($_COOKIES['somecookie'])

                  As for your first point (no redirection) don't have any ideea for now ... 🙁. Your solution seems better from this point of view.

                    Hi

                    You're right, you could add that check in at the top of the forward to page, and bump them right back if they had avoided the index page!

                    I will have a look at putting a check for java in the code also, next week maybe.

                    Trevor

                      Write a Reply...