note 91124 deleted from function.session-register by cmb
| From: | cmb@php.net | Date: | Wed, 24 Feb 2021 12:11:05 +0000 |
| Subject: | note 91124 deleted from function.session-register by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-219231@lists.php.net to get a copy of this message | ||
Note Submitter: david dot demri at gmail dot com
----
If you have an old code with a lot of call to the function session_register(), and you would like to
make it compatible with PHP5 or PHP6, instead of rewriting all your code by replacing this function
by $_SESSION['var']="val"; you could use the function set_session_vars(), that
is used exactly the same way than session_register() (but there is no implicit call to
session_start() ).
<?php
function set_session_vars() {
$nb_args=func_num_args();
$arg_list=func_get_args();
for($i=0;$i<$nb_args;$i++) {
global $$arg_list[$i];
$_SESSION[$arg_list[$i]] = $$arg_list[$i];
}
}
?>