• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

session,cookie共用,session丢失之有关问题,1周了

php 搞代码 3年前 (2022-01-23) 44次浏览 已收录 0个评论

session,cookie共用,session丢失之问题,1周了。
cookie只保存了一个自动登录。
session,是存着所在导般栏名子,(中英名系统)。共有近30个。如:

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$session['userInfo']='用户中心';

所有session都在head.php中,被所有文件来引用。
部分代码如下:

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php if(($_POST['admin_user']!="")&&($_POST['admin_pass']!="")){    require_once("image/conn.php");        $number=(get_magic_quotes_gpc())?trim($_POST['admin_user']):addslashes(trim($_POST['admin_user']));    $pass=(get_magic_quotes_gpc())?trim($_POST['admin_pass']):addslashes(trim($_POST['admin_pass']));        $q=$m->query("select authority from setting_user where number='".$number."' and password='".$pass."'");    $r=$q->fetch_array(MYSQLI_USE_RESULT);    (int)$authority=$r['authority'];//权限分配        if($q->num_rows>0){        //分配显示名        $qShow=$m->query("select * from setting_display where user='".$number."' order by id desc limit 1");        $rShow=$qShow->fetch_array(MYSQLI_USE_RESULT);{            $_SESSION['receiving']=$rShow['receiving']?$rShow['receiving']:NULL;            $_SESSION['po']=$r<strong>*本文来@源gao@daima#com搞(%代@#码@网2</strong><pre>搞代gaodaima码

Show[‘po’]?$rShow[‘po’]:NULL; // 很多session 在这里 if($_POST[‘remeberMe’]){ setcookie(“u”,$number,time()+3600); setcookie(“p”,$pass,time()+3600); } } $_SESSION[‘auth’]=$number; switch($authority){ case 1:echo “<script>window.location.href=’main.php?o=show’;</script>”;$_SESSION[‘admin’]=1;break; default:echo “<script>window.location.href=’main.php?o=show’;</script>”;$_SESSION[‘admin’]=NULL;break; } } else{ echo “<script language=javascript>alert(‘用户名或密码输入错误!’);</script>”; }}?>

每个页面,都加了,

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php session_set_cookie_params('3600');session_start(); ?>

这些session是从数据里取的,但是为什么,使用不到80秒,就会出现乱的名子,由汉字(正确)变化,数字与字母的。

——解决方案——————–
出现乱的名子?

页面的编码是否一致?
——解决方案——————–
中间是不是改动了session或者cookies的值。是不是session_set_cookie_params的原因


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:session,cookie共用,session丢失之有关问题,1周了
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址