老问题重提,为什么不断刷新,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); } } php二维数组排序 php产生均匀随机数 Warning: session_start(): open 听别人说有个自动生成网站的工具,那位知道有好的吗? 求php的安装包 session_start()无法运用 在再简化代码需求~~ php用什么编辑器 如何能得到当前php文件所在的目录? 怎样捕捉鼠标事件? 关于排名问题 求助!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);
}
}