老问题重提,为什么不断刷新,session还是会失效? 从原理上来讲,当一个页面不断被刷新(如5分钟刷新一次)那么,session是不会过期的,但是在实际测试中发现,即使这样,session仍然还是会失效,请问这是为什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在PHP中,设置php.ini,找到 session.gc_maxlifetime = 1440 (PHP5默认24秒) 这里你可以随便设置一下过期时间.但是有人说设置以后,好象不起作用! 其实不是不起作用,而是因为系统默认: session.gc_probability = 1 session.gc_divisor = 1000也就是说,garbage collection 有个概率的,1/1000就是session 1000次才有一次被回收。只要你的访问量大然你了,那就能达到回收的效果.要不也可以设置一下 session.gc_divisor 的值,比如:session.gc_divisor = 1,这样就能明显的看到SESSION过期的效果了. 如果 要想 session 不过期的话,直接 设置 session.gc_divisor = 0;本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/phpBoy005/archive/2009/05/17/4194975.aspx session是有过期时间的,可以在php.ini里设置session.gc_maxlifetime=...;php.ini关于Session的相关设置(打开php.ini文件,在“[Session]”部分): 1、session.use_cookies:默认的值是“1”,代表SessionID使用Cookie来传递,反之就是使用Query_String来传递; 2、session.name:这个就是SessionID储存的变量名称,可能是Cookie,也可能是Query_String来传递,默认值是“PHPSESSID”; 3、session.cookie_lifetime:这个代表SessionID在客户端Cookie储存的时间,默认是0,代表浏览器一关闭SessionID就作废……就是因为这个所以Session不能永久使用 4、session.gc_maxlifetime:这个是Session数据在服务器端储存的时间,如果超过这个时间,那么Session数据就自动删除 有个比较好的资料,你可以去看一下的:http://www.3389hack.com/xueyuan/zhanzhang/jichu/21121.html 哪位能从PHP的源码内部原理上分析一下呢 public static void renderDownload(HttpServletRequest request, HttpServletResponse response, final String fileName, InputStream in) throws IOException { String mimetype = "application/octet-stream"; String encodeName = fileName; String ua = request.getHeader("User-Agent"); if (-1 != ua.toLowerCase().indexOf(" msie ")) { // 客户端为IE try { encodeName = java.net.URLEncoder.encode(fileName, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } mimetype = " application/x-msdownload "; } else { //非IE encodeName = MimeUtility.encodeText(fileName, "UTF8", "B"); mimetype = " application/x-download "; } response.reset(); response.setContentType(mimetype); response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\""); OutputStream out = null; try { out = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int i = -1; while ((i = in.read(buffer)) != -1) { out.write(buffer, 0, i); } response.flushBuffer(); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(in); } } emai正则 有关php中md5加密数据库内的数据的程序,急用!谢谢了 模拟登陆163邮箱并获取联系人地址怎么获取不到?错在哪里? 大家帮忙看看这段代码的防SQL注入效果如何?谢谢 关于php递归的问题 谁有xajax库的压缩文件,发个地址啊.官方网站最近打不开 mysql条件使用or查询不会触发索引? 连接MySql数据库的问题?????????? 两个类的概念问题:关于类中函数得的“默认值”及其他 #1241 - Operand should contain 1 column(s) 关于排名问题 求助!phpweb安装时出错,不知该如何解决!
session.gc_divisor = 1000也就是说,garbage collection 有个概率的,1/1000就是session 1000次才有一次被回收。只要你的访问量大然你了,那就能达到回收的效果.要不也可以设置一下 session.gc_divisor 的值,比如:session.gc_divisor = 1,这样就能明显的看到SESSION过期的效果了. 如果 要想 session 不过期的话,直接 设置 session.gc_divisor = 0;
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/phpBoy005/archive/2009/05/17/4194975.aspx
session.gc_maxlifetime=...;php.ini关于Session的相关设置(打开php.ini文件,在“[Session]”部分):
1、session.use_cookies:默认的值是“1”,代表SessionID使用Cookie来传递,反之就是使用Query_String来传递;
2、session.name:这个就是SessionID储存的变量名称,可能是Cookie,也可能是Query_String来传递,默认值是“PHPSESSID”;
3、session.cookie_lifetime:这个代表SessionID在客户端Cookie储存的时间,默认是0,代表浏览器一关闭SessionID就作废……就是因为这个所以Session不能永久使用
4、session.gc_maxlifetime:这个是Session数据在服务器端储存的时间,如果超过这个时间,那么Session数据就自动删除
http://www.3389hack.com/xueyuan/zhanzhang/jichu/21121.html
InputStream in) throws IOException {
String mimetype = "application/octet-stream";
String encodeName = fileName;
String ua = request.getHeader("User-Agent");
if (-1 != ua.toLowerCase().indexOf(" msie ")) {
// 客户端为IE
try {
encodeName = java.net.URLEncoder.encode(fileName, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
mimetype = " application/x-msdownload ";
} else {
//非IE
encodeName = MimeUtility.encodeText(fileName, "UTF8", "B");
mimetype = " application/x-download ";
}
response.reset();
response.setContentType(mimetype);
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"");
OutputStream out = null;
try {
out = response.getOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
int i = -1;
while ((i = in.read(buffer)) != -1) {
out.write(buffer, 0, i);
}
response.flushBuffer();
} finally {
IOUtils.closeQuietly(out);
IOUtils.closeQuietly(in);
}
}