Man, al pedo te vas a complicar tanto... y lo que decis no se puede hacer por que de cualquier forma tenes que pasarle por GET o POST el valor a la variable de sesion... y no es muy buena idea llenar tu server con variables de sesion creo que podria afectar la performance y no creo que quieras eso...
la inseguridad que tienen Get o Post son las inyecciones sql, pero eso es facil de solucionar...
usa esta funcion:
Código PHP:
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
Ejemplo de como usar:
Código PHP:
$variable=GetSQLValueString($_GET['Id'],"int");
y listo esta limpia tu variable $_GET['Id']...
esa funcion lo que hace es limpiar la variable GET o POST... con mysql_real_escape_string , stripslashes y get_magic_quotes_gpc y tambien validando el tipo de dato...