Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Session Cookies</strong></p> <p>Remember that HTTP is <strong>stateless</strong>, so sessions are tracked on your server, but the <strong>client</strong> has to identify itself with each request. When you declare session_start(), <strong>your browser is usually setting a cookie</strong> (the "PHP Session Id"), and then identifying itself by sending the cookie value with each request. When a script is called using a request with a session value, then the session_start() function will try to look up the session. To prove this to yourself, notice that sessions die when you clear your cookies.. many will die even as soon as you quit the browser, if the cookie is a "session" cookie (a temporary one). You mentioned that you're naming the session.. take a look in your browser cookies and see if you can find a cookie with the same name.</p> <p>All of this is to say that cookies are playing an active role in your sessions, so if the <strong>client doesn't support cookies</strong>, then you can't do a session the way you're currently doing it.. at least not for those alternative clients. A session will be created on the server; the question is whether or not the client is participating.</p> <p>If cookies aren't an option for your client, you're going to have to find <strong>another way</strong> to pass a session id to the server. This can be done in the <strong>query string</strong>, for example, although it's a considered a bit less private to send a session id in this way.</p> <pre><code>mysite.com?PHPSESSID=10alksdjfq9e </code></pre> <p>How do to this specifically may vary with your version of PHP, but it's basically just a configuration. If the proper runtime options are set, PHP will transparently add the session id as a query parameter to links on the page (same-source only, of course). You can find the specifics for setting that up on the <a href="http://us2.php.net/manual/en/session.idpassing.php" rel="noreferrer">PHP website</a>.</p> <p><strong>Sidenote:</strong> Years ago, this was a common problem when attempting to implement a session. Cookies were newer and many people were turning off the cookie support in their browsers because of purported security concerns.</p> <p><strong>Sidenote:</strong> <em>@Uberfuzzy</em> makes a good point- Using sessions with curl or wget is actually possible. The problem is that it's less automatic. A user might dump header values into a file and use the values on future requests. curl has some "cookie awareness" flags, which allow you to handle this more easily, but you still must explicitly do it. Then again, you could use this to your advantage. If curl is available on your alternative client, then you can plausibly make the call yourself, using the cookie awareness flags. Refer to the <a href="http://curl.netmirror.org/docs/manual.html" rel="noreferrer">curl manual</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload