Note that there are some explanatory texts on larger screens.

plurals
  1. POReload page, keep sessions
    text
    copied!<p>I'm trying to develop a function where a user can click "Previos week"/"Next week" and that will trigger some <code>$_SESSION</code> variables to change values (dates).</p> <p>I have this code on <strong>absence.php</strong> (I know that PRG pattern is not implemented. I have no idea on how to do this but still keep functionality).</p> <pre><code>&lt;?php if (isset($_POST['decrease_date'])) { $monday_value = ($_SESSION['sess_mon'] = strftime("%Y-%m-%d", strtotime("{$_SESSION['sess_mon']} -1 day")) ); } if (isset($_POST['increase_date'])) { $monday_value = ($_SESSION['sess_mon'] = strftime("%Y-%m-%d", strtotime("{$_SESSION['sess_mon']} +1 day")) ); } else { $monday_value = ($_SESSION['sess_mon'] = date('Y-m-d', strtotime('Monday this week')) ); } ?&gt; &lt;form action='absence.php' method='post'&gt; &lt;input type="hidden" name="decrease_date"/&gt; &lt;input type='submit' value='Previous'&gt; &lt;/form&gt; &lt;form action='absence.php' method='post'&gt; &lt;input type="hidden" name="increase_date"/&gt; &lt;input type='submit' value='Next'&gt; &lt;/form&gt; </code></pre> <p>Now I would like to reload the page (with jQuery <code>location.reload()</code>-function) but still keep the <code>$_SESSION</code>s what was active at the moment before the page was refreshed. Currently this will "reset" since there is no <code>$_POST</code>.</p> <p>Ideally I would like to send the <code>&lt;form action'#'&gt;</code> to another page. However when you first enter <strong>absence.php</strong> the dates should be reset.</p> <p>How would I do this?</p>
 

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