Fabio Ferreira Posted February 28, 2012 Report Share Posted February 28, 2012 Tenho o seguinte codigo escrito para php 4.1, quero passar para o a versao 5.3.Esta aparecendo o seguinte erro :Deprecated: Function session_register() is deprecated in C:\wamp\www\comercio\INCLUDES\functions\SESSIONS.PHP on line Este é o codigo que tenho para passar para a versao 5.3:<?php if (STORE_SESSIONS == 'mysql') { if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) { $SESS_LIFE = 1440; } function _sess_open($save_path, $session_name) { return true; } function _sess_close() { return true; } function _sess_read($key) { $qid = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . $key . "' and expiry > '" . time() . "'"); if (list($value) = tep_db_fetch_array($qid)) { return $value; } return false; } function _sess_write($key, $val) { global $SESS_LIFE; $expiry = time() + $SESS_LIFE; $value = addslashes($val); $qid = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . $key . "'"); list($total) = tep_db_fetch_array($qid); if ($total > 0) { return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . $expiry . "', value = '" . $value . "' where sesskey = '" . $key . "'"); } else { return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . $key . "', '" . $expiry . "', '" . $value . "')"); } } function _sess_destroy($key) { return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . $key . "'"); } function _sess_gc($maxlifetime) { tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'"); return true; } session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); } function tep_session_start() { return session_start(); } function tep_session_register($variable) { return session_register($variable); } function tep_session_is_registered($variable) { return session_is_registered($variable); } function tep_session_unregister($variable) { return session_unregister($variable); } function tep_session_id($sessid = '') { if ($sessid != '') { return session_id($sessid); } else { return session_id(); } } function tep_session_name($name = '') { if ($name != '') { return session_name($name); } else { return session_name(); } } function tep_session_close() { if (function_exists('session_close')) { return session_close(); } } function tep_session_destroy() { return session_destroy(); } function tep_session_save_path($path = '') { if ($path != '') { return session_save_path($path); } else { return session_save_path(); } }?> Quote Link to comment Share on other sites More sharing options...
0 MLeandroJr! Posted February 28, 2012 Report Share Posted February 28, 2012 Você pode sempre consultar a documentação do PHP para entender o que são as mensagens e como resolvê-las.No caso do seu erro, dá uma olhada aqui: http://br2.php.net/manual/pt_BR/function.s...on-register.phpCom certeza possui uma solução.Com essa documentação ficará fácil você converter seu script para as versões mais novas do PHP. Quote Link to comment Share on other sites More sharing options...
Question
Fabio Ferreira
Tenho o seguinte codigo escrito para php 4.1, quero passar para o a versao 5.3.
Esta aparecendo o seguinte erro :
Deprecated: Function session_register() is deprecated in C:\wamp\www\comercio\INCLUDES\functions\SESSIONS.PHP on line
Este é o codigo que tenho para passar para a versao 5.3:
<?php
if (STORE_SESSIONS == 'mysql') {
if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
$SESS_LIFE = 1440;
}
function _sess_open($save_path, $session_name) {
return true;
}
function _sess_close() {
return true;
}
function _sess_read($key) {
$qid = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . $key . "' and expiry > '" . time() . "'");
if (list($value) = tep_db_fetch_array($qid)) {
return $value;
}
return false;
}
function _sess_write($key, $val) {
global $SESS_LIFE;
$expiry = time() + $SESS_LIFE;
$value = addslashes($val);
$qid = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . $key . "'");
list($total) = tep_db_fetch_array($qid);
if ($total > 0) {
return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . $expiry . "', value = '" . $value . "' where sesskey = '" . $key . "'");
} else {
return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . $key . "', '" . $expiry . "', '" . $value . "')");
}
}
function _sess_destroy($key) {
return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . $key . "'");
}
function _sess_gc($maxlifetime) {
tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");
return true;
}
session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
}
function tep_session_start() {
return session_start();
}
function tep_session_register($variable) {
return session_register($variable);
}
function tep_session_is_registered($variable) {
return session_is_registered($variable);
}
function tep_session_unregister($variable) {
return session_unregister($variable);
}
function tep_session_id($sessid = '') {
if ($sessid != '') {
return session_id($sessid);
} else {
return session_id();
}
}
function tep_session_name($name = '') {
if ($name != '') {
return session_name($name);
} else {
return session_name();
}
}
function tep_session_close() {
if (function_exists('session_close')) {
return session_close();
}
}
function tep_session_destroy() {
return session_destroy();
}
function tep_session_save_path($path = '') {
if ($path != '') {
return session_save_path($path);
} else {
return session_save_path();
}
}
?>
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.