English 中文(简体)
Remove Cookies from JS or CSS files
原标题:

Bizarrely my javascript and css files have cookies (says Firebug). I use Zend Framework and I think it has to do with it. Could I change the .htaccess that CSS or JS files don t link to the ZF or is there another solution?

.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

In my bootstrap file I start the session automaticly, could I detect there really existing files and deactive sessions/cookies?

问题回答

Cookies aren t in js or CSS files: they are transferred over the HTTP headers.

You can minimize the space they take but if you rely on them, you can t really get rid of them. You can always "move" the static files someplace else so you don t incur the "cost" of the additional headers e.g. cookies. Other place being --> other domain where you suppress cookies altogether.

You can place your CSS and JavaScript files and your Images on a "static" webserver or subdomain which does not accept cookies. There are two very good explanations out there:

Cookies are set per domain, so the browser will send them along with every request it makes to that domain, regardless what type of resource it is requesting.

You can remove useless cookies. Example on htaccess with apache :

<FilesMatch ".(css|js|png|gif|jpg|jpeg)$"> 
     Header unset Cookie 
     Header unset Set-Cookie 
</FilesMatch> 

It seems there is a way :

Header unset Set-Cookie




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签