could direct or me wit make_cookie function ? create redirect loop , page won't load. appeared after upgrading php 5.3 php 5.5 , have compared php.ini files
function make_cookie($name,$value,$time,$loc=0) { global $query_string, $db_handler, $user; if($this->cookies) { setcookie($name,$value,$time); } else { $query="select t2.*,t1.id sess session t1 ". "left join user t2 on t1.user=t2.id ". "where t1.last_ip='".$_server["remote_addr"]."' ". "and t1.cookie='".$value."' , t1.out_time>now()"; $result=mysqli_query($db_handler,$query) or die(mysqli_error($db_handler)); if($rida=mysqli_fetch_assoc($result)) { //define("_asutus_id",$rida["asutus_id"]); $user_id=$rida["id"]; $mods_text=$this->get_mods($user_id); $user1_text=$this->get_user1($user_id); $fl=fopen("tmp/$value.inc","w+"); fwrite($fl,"<?\n"); fwrite($fl,"\$globals[\"mod_rights\"]=".$mods_text.";\r\n"); fwrite($fl,"\$globals[\"user1\"]=".$user1_text.";\r\n"); fwrite($fl,"?>\n"); fclose($fl); $fl=fopen("tmp/".$value."_1.inc","w"); fwrite($fl,"<?\n"); fwrite($fl,"\$globals[\"tooted\"]=array();\r\n"); fwrite($fl,"?>\n"); fclose($fl); //$query=mysql_query("update session set rights='$rights_text',mods='$mods_text' id=".$rida["sess"]) or die(mysql_error()); mysqli_free_result($result); } $qry_str=preg_replace("/sessid=[0-9a-f]{32,32}/i","",$query_string); header("location: index.php?sessid=".$value."&".$qry_str); } }
i calling in function
function new_sess($loc=0) { global $user,$db_handler; $token=md5(microtime()); $expires=time()+3600; $exp=date("y-m-d h:i:s", $expires); mysqli_query($db_handler, "insert session (cookie, in_time, out_time, last_ip, ipname) values ('".$token."', now(), '".$exp."', '".$_server["remote_addr"]."', '".gethostbyaddr($_server["remote_addr"])."')") or die(mysqli_error($db_handler)); $this->sessid=$token; $this->make_cookie("sessid",$token,time()+3600,$loc); $user=''; log_("new_session","_"); }
Comments
Post a Comment