note 8815 added to Session handling functions
| From: | s dot vanvelthem at ibelgique dot com | Date: | Fri, 29 Sep 2000 04:58:34 +0000 |
| Subject: | note 8815 added to Session handling functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-5577@lists.php.net to get a copy of this message | ||
I write a little piece of code that makes session management "cookie-less" and
"POST-enabled" without adding session variable in the URL. It uses the hidden form tag to
pass variables. So you can easily process them in your php code (they will be in $HTTP_POST_VARS)
<?
if (!isset($sid)) {
session_start();
} else {
session_id($sid);
session_start();
}
session_register("counter");
(...)
echo '<form name="test" method="post">';
echo '<input type="submit" name="" value="">';
echo '<input type="hidden" name=sid value="' . session_id() .
'">';
</form>
To make your get action into post action : just add this javascript in place of the <a
href=...> (<a href="javascript:go(1)">blahblah</a>.
<script>
function go(num) {
/* you can change the value of a hidden form here. for example : link to another page...
hiddenfield.value = num;
*/
document.test.submit();
}
</script>
It works fine. Your URL is still clean and you don't have to worry about cookies related
problems (proxy...)
Please let me know your comments.
http://www.php.net/manual/ref.session.php