Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So what about storing any of the URI data is a session array and when a specific key is requested by the user use the received key and replace it by your actual URI stored in the $_SESSION array? when generating a uri you could have a method store it for you and return a replacing URI like so (note that you should have session already started that should not be part of this objects scope):</p> <pre><code>class URIStore{ private $URIstoreID; private $SUPERSECRETSALT; private $storeName; const STORE_EXCEPTION_EXPIRED = 0; const STORE_EXCEPTION_CSRF = 1; public function __construct($storename){ //retreive existing store ID so we can built on previous $this-&gt;URIstoreID = isset($_SESSION[$storename]['URIStoreID']) ? $_SESSION[$storename]['URIStoreID'] : 0; $this-&gt;SUPERSECRETSALT = 'jsf098u32rojwe092';//salt could be made random here $this-&gt;storename = $storename; } /** * stored the $uri data in a session for later retrieval through the returned key * @param mixed $uri - can be anything that you want, like a key value pair array * @return string */ public function store($uri){ $r = md5($this-&gt;URIStoreID.$this-&gt;SUPERSECRETSALT); $_SESSION[$this-&gt;storename][$r] = $uri; $this-&gt;URIStoreID++; $_SESSION[$this-&gt;storename]['URIStoreID'] = $this-&gt;URIStoreID; return $r; } /** * returns a previously stored URI item * @param string $key - the key you want to get the URI data for * @return mixed * @Throws Exception - when Store or Key doesnt exist */ public function retrieve($key){ if(!isset($_SESSION[$this-&gt;storename]){ //the initial session has expired throw new Exception("URIStore [$this-&gt;storename] does not exists",self::STORE_EXCEPTION_EXPIRED); } elseif(!isset($_SESSION[$this-&gt;storename][$key]){ //the requested key does not exist //could be CSRF attempt? throw new Exception("URIStore [$this-&gt;storename] does not contain this key",self::STORE_EXCEPTION_CSRF); } return $_SESSION[$this-&gt;storename][$key]; } } </code></pre> <p>the use the above you could do the following when building a URL</p> <pre><code>$store = new URIStore('URIStore'); $URL = SERVER_URL . 'yourscriptthathandlestherequest.php?key=' . $store-&gt;store(array('a'=&gt;1,'b'=&gt;23)); </code></pre> <p>and when you retrieve a request you first get the actual data instead of get data like </p> <pre><code>$store = new URIStore('URIStore'); try{ $data = $store-&gt;retrieve(@$_GET['key']); } catch(Exception $e){ switch($e-&gt;getCode()){ case URIStore::STORE_EXCEPTION_EXPIRED: //handle accordingly break; case URIStore::STORE_EXCEPTION_CSRF: //handle accordingly break; } } </code></pre> <p>note that in your case GET is fine, for CRUD actions I would highly suggest using POST</p> <p>the Session will expire when no requests are made for a while (depends on server settings) if you want different expirations for different items (still limited to the session expiration time as a maximum though) you would add another layer to the array that stores the uri and an additional timestamp that you have the URIStore::retrieve method compair against. and finally you could use multiple stores for different things if you wanted. so that you only use the one you expect on a certain page.</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.
    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