Codeigniter重复会话问题

编程入门 行业动态 更新时间:2024-10-26 17:25:10
本文介绍了Codeigniter重复会话问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个用codeigniter构建的应用程序,使用sessions类并在数据库中存储会话数据。问题是当我的网页加载一个css文件时,我在数据库中得到额外的会话记录。

直到最近我在一个简单的VPS主机上运行我的应用程序通过rackspace。数据库和Apache都在同一个VPS上运行。不过,我最近将我的应用程式迁移至

任何人都知道可能导致这种情况?谢谢!

更新: 我意识到页面的html可能会有所帮助。注释样式表包括在第13行使问题消失。 pastebin/iBEb4he6

UPDATE2:

$ config ['sess_cookie_name'] ='ci_session' $ config ['sess_expiration'] = 7200; $ config ['sess_expire_on_close'] = FALSE; $ config ['sess_encrypt_cookie'] = FALSE; $ config ['sess_use_database'] = TRUE; $ config ['sess_table_name'] ='ci_sessions'; $ config ['sess_match_ip'] = FALSE; $ config ['sess_match_useragent'] = TRUE; $ config ['sess_time_to_update'] = 300; / * | ----------------------------------- --------------------------------------- | Cookie相关变量 | ------------------------------------------ -------------------------------- | | 'cookie_prefix'=如果您需要避免冲突,请设置前缀 | 'cookie_domain'=设置为.your-domain网站范围的Cookie | 'cookie_path'=通常为正斜杠 | 'cookie_secure'=仅当存在安全HTTPS连接时才设置Cookie。 | * / $ config ['cookie_domain'] ='casey.phpfogapp'; // $ base_url_parts ['host']; $ config ['cookie_path'] ='/'; $ config ['cookie_prefix'] =; $ config ['cookie_secure'] = FALSE;

解决方案

在我的应用程序中,我将以下代码放入.htaccess用于阻止使用css / js / images请求发送Cookie:

#。htaccess #使用Mod_deflate压缩静态文件< ifmodule mod_deflate.c> < filesmatch。(js | css | ico | txt | htm | html | php)$> SetOutputFilter DEFLATE < / filesmatch> < / ifmodule> #加快缓存 FileETag MTime大小 #到期 ExpiresActive开 ExpiresDefault访问加366天 #Future Expires Headers < filesmatch。(ico | pdf | flv | jpg | jpeg | png | gif | js | css | swf)$> Header set ExpiresSat,27 Dec 2014 23:59:59 GMT< / filesmatch>

I have an application built with codeigniter using the sessions class and storing session data in a database. The problem is I'm getting extra session records in my database when my webpage loads a css file.

Up until recently I was running my application on a simple VPS host provided by rackspace. Database and Apache were both running on the same VPS. Recently however I've migrated my application to PHPFog to allow it to scale more easily. I didn't have this issue with my former hosting setup.

The row with the populated value for user_data is my original session. The other three blank sessions are the result of simply refreshing the page three times. I seem to have tracked it down to including a css file in my header, when I comment it out or delete it the issue goes away. It's only this particular css file also, other css/js/image files don't cause this issue.

Here is a link to the css file in question: pastebin/XfEBNFiC

Anyone know what could be causing this? Thanks!

UPDATE: I realized the html of the page in question might be helpful. Commenting out the stylesheet include on line 13 makes the issue go away. pastebin/iBEb4he6

UPDATE2:

$config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_expire_on_close'] = FALSE; $config['sess_encrypt_cookie'] = FALSE; $config['sess_use_database'] = TRUE; $config['sess_table_name'] = 'ci_sessions'; $config['sess_match_ip'] = FALSE; $config['sess_match_useragent'] = TRUE; $config['sess_time_to_update'] = 300; /* |-------------------------------------------------------------------------- | Cookie Related Variables |-------------------------------------------------------------------------- | | 'cookie_prefix' = Set a prefix if you need to avoid collisions | 'cookie_domain' = Set to .your-domain for site-wide cookies | 'cookie_path' = Typically will be a forward slash | 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists. | */ $config['cookie_domain'] = 'casey.phpfogapp'; //$base_url_parts['host']; $config['cookie_path'] = '/'; $config['cookie_prefix'] = ""; $config['cookie_secure'] = FALSE;

解决方案

In my applications I place the following code into .htaccess for preventing a cookie to be sent with css/js/images requests:

#.htaccess # Use Mod_deflate to compress static files <ifmodule mod_deflate.c> <filesmatch ".(js|css|ico|txt|htm|html|php)$"> SetOutputFilter DEFLATE </filesmatch> </ifmodule> # Speed up caching FileETag MTime Size # Expires ExpiresActive On ExpiresDefault "access plus 366 days" # Future Expires Headers <filesmatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Expires "Sat, 27 Dec 2014 23:59:59 GMT" </filesmatch>

更多推荐

Codeigniter重复会话问题

本文发布于:2023-10-11 22:21:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483007.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!