note 114940 added to function.register-shutdown-function
| From: | m dot agkopian at gmail dot com | Date: | Wed, 30 Apr 2014 22:29:31 +0000 |
| Subject: | note 114940 added to function.register-shutdown-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199394@lists.php.net to get a copy of this message | ||
Use this small snippet inside your bootstrap in order to always have a way to know reliably what was
the last page of your site that the user have visited, without having to use
$_SERVER['HTTP_REFERER'].
<?php
session_start();
// Get current page
$current_page = htmlspecialchars($_SERVER['SCRIPT_NAME'], ENT_QUOTES, 'UTF-8');
$current_page .= $_SERVER['QUERY_STRING'] ?
'?'.htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES, 'UTF-8') :
'';
// Set previous page at the end
register_shutdown_function(function ($current_page) {
$_SESSION['previous_page'] = $current_page;
}, $current_page);
?>
----
Server IP: 72.52.91.14
Probable Submitter: 46.177.108.171
----
Manual Page -- http://php.net/manual/en/function.register-shutdown-function.php
Edit -- https://master.php.net/note/edit/114940
Del: integrated -- https://master.php.net/note/delete/114940/integrated
Del: useless -- https://master.php.net/note/delete/114940/useless
Del: bad code -- https://master.php.net/note/delete/114940/bad+code
Del: spam -- https://master.php.net/note/delete/114940/spam
Del: non-english -- https://master.php.net/note/delete/114940/non-english
Del: in docs -- https://master.php.net/note/delete/114940/in+docs
Del: other reasons-- https://master.php.net/note/delete/114940
Reject -- https://master.php.net/note/reject/114940
Search -- https://master.php.net/manage/user-notes.php