Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many ways you can do this, and the easiest (and most transparent way of doing so) is by setting a session cookie. This is a small file that sits on the client's computer, and is readable by all sites on your sub-domain (x.mydomain.com.), basically all files in that same folder as the file that set it. You can do this easily in PHP by doing the following things:</p> <ol> <li><p>On EVERY page you want to set, get, or otherwise check for the variables... use this code</p> <pre><code>session_start(); // Put this at the TOP of your page, below &lt;? or just before you check the variables. </code></pre></li> <li><p>On the page you want to SET the variables... use this code</p> <pre><code>$_SESSION['variable'] = "data"; session_write_close(); // Use this after you are done setting the session data, to save it before the page execution is finished. This is a good habit to get in to, it's kind of like when you fclose a file instead of waiting for the script to do it. </code></pre></li> <li><p>On the page you want to GET the variables.. use this code</p> <pre><code>$test = $_SESSION['variable']; </code></pre></li> </ol> <p>You can basically use the $_SESSION array to store variables you want to be seen as "global" on your site. Forums use this to store the User ID and session hash, for later authentication on passwords. Other sites use session cookies to limit user activity within a given timeframe.</p> <p>--</p> <p>There is also another way you can do this, have a link from your page that generates the value of $test send a GET request to index.php (for example, if the user clicks a link format the link like:</p> <pre><code>index.php?test=value </code></pre> <p>Then on index.php simply do:</p> <pre><code>$test = $_GET{'test']; </code></pre> <p>This method is good for users who may not have cookie support, or may have cookies disabled; but is very obvious, and users can easily change the value of the cookie (which can have unseen results.)</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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