cookies

in a website, setting one cookie is better than setting many single cookies?

倖福魔咒の 提交于 2020-01-03 05:23:06
问题 Suppose that you have to set 12 cookies, would it be better to store all of their values in a single "big" cookie or store each value on its own cookie? I want to know if that improves website speed. Thanks. 回答1: I think the maximium size of a cookie is about 4k. If you need to store more data than that, then you're better off using several cookies. i don't think there will be a big performance issue using multiple cookies. in my opinion, it may be more efficient to store each piece of data

GDPR Compliance on static sites

喜夏-厌秋 提交于 2020-01-03 04:55:46
问题 It's been a while already since almost all sites I visit pop-up a message regarding cookies and such. I never understood why but, ignorantly, I always clicked "OK". Fearing that could interfere with Google AdSense, YouTube, Vimeo or even Facebook (Comments Plugin) I use, I tried to understand a bit more, even to not give any excuse for not get paid (when applicable). Then I read, in general lines, the part that I care most (since I have no contact forms or user registration) that "unless

serialize form to json and store in the cookie

烈酒焚心 提交于 2020-01-03 04:53:10
问题 i want to store form on clientside, in json in cookie, after that deserialize it back to form. what i'm doing: serialization to JSON: function formToJSON(selector) { var form = {}; $(selector).find(':input[name]:enabled').each(function () { var self = $(this); var name = self.attr('name'); if (name.indexOf('TextBox', 0) == 0) { if (form[name]) { form[name] = form[name] + ',' + self.val(); } else { form[name] = self.val(); } } }); return form; } then on form change, i'm trying to save form to

HTML5 video seeking in CakePHP

半城伤御伤魂 提交于 2020-01-03 04:45:28
问题 I have video streaming working just fine in CakePHP. Since the videos are private to each user, I have a CakePHP controller serve up the files if the users are authenticated. I also notice that all requests sent to the server have a Cookie: CAKEPHP=<stuff> header in their request. The problem is that when a user pauses, then plays the video or when the user seeks along the video, Chrome sends a Range request with a certain byte range for my server to deliver. The request gets cancelled

How to keep state at the client SAFELY?

邮差的信 提交于 2020-01-03 03:17:07
问题 Following this question: Can a cookie that was generated with Javascript (not send in the header by the server) be stolen / used by an attacker? This is driving me crazy. How can one ever keep state at the client using a FB access token? One should use it to access resources on one's own server, and also from the FB server. Assuming that one uses a js framework (Backbone / Marionette) and REST authentication. It cannot be encrypted as such, and yet there is no other way than to use a cookie

Hide and Show content based on Cookie value

馋奶兔 提交于 2020-01-03 03:03:16
问题 Here is my Jquery: $("#tool").click(function() { $(".chelp").slideToggle(); $("wrapper").animate({ opacity: 1.0 },200).slideToggle(200, function() { $("#tool img").toggle(); }); }); When you click #tool img #wrapper is hidden along with .chelp . I need to control this with a cookie, so when the user hides #wrapper it remains hidden on all pages or when they re-visit the page. I know there is a jQuery Cookie plugin, but I'd like to do this with plain Javascript rather then including another

How to store dyanamic value into jquery cookie variable

让人想犯罪 __ 提交于 2020-01-03 02:51:06
问题 How can we store dynamic variables into cookie . var username = ($("#username").val()); how to store the variable username into jquery cookie variable $.cookie('username', '+username +'); alert($.cookie('username')); 回答1: If you put within a single quotes it takes only string.So for this you don't need the single quotes for assigning the value. Try this $(document).ready(function() { var username = ($("#username").val()); $.cookie('username', username ); alert($.cookie('username')); }); It

HTTP cookie between two HTML pages

夙愿已清 提交于 2020-01-03 00:53:14
问题 I have two HTML pages. After entering few inputs users will be redirected from first page to second page. Before redirecting the user to second HTML page(using window.location="new HTML URL"), I persist few of the user inputs in cookie using document.cookie DOM API. When I am in the second HTML page, I could not retrieve the value from this cookie. I think since document object would have changed in the new HTML page, my cookie values become inaccessible. Can someone tell me: how do I

How can I disable URL-encoding of cookies in Rails

久未见 提交于 2020-01-02 18:09:12
问题 I have a Rails application that has to co-exist with a very old legacy application. The legacy application looks for a cookie that has a value containing a specific string of characters. Unfortunately, the characters in the legacy cookie often contain slashes. The problem I have is that when the Rails application writes the cookie it first does URL-encoding which causes the legacy app to break because the cookie values is incorrect. I had this working in Rails 1.13.5 by editing the file

不要把 JWT 用作 session

本小妞迷上赌 提交于 2020-01-02 10:47:00
现在很多人使用 JWT 用作 session 管理,这是个糟糕的做法,下面阐述原因,有不同意见的同学欢迎讨论。 首先说明一下,JWT 有两种: 无状态的 JWT,token 中包含 session 数据。 有状态的 JWT,token 中仅有 session ID,session 数据还是存储在服务端。 本文讨论的是 “无状态的 JWT”,就是把用户的 session 数据放到 token 中。 JWT 不适合做为 session 机制,这么做是有危险的。 很多人喜欢比较 “cookies vs. JWT”,这种比较是无意义的,就像比较苹果和桔子,cookies 是一个存储机制,而 JWT 是加密签名的 token,他们不是对立的,可以一起使用,或者独立使用。 正确的比较是“ sessions vs. JWT” 和 “cookies vs. Local Storage”。 JWT 宣称的优点 人们通常会说 JWT 有如下的好处: 易于水平扩展 简单易用 加密,更安全 内置过期功能 可以防护 CSRF 攻击 在用户阻止了cookies后还可以工作 对于这些所谓的好处我们会一一剖析。 (1)易于水平扩展 把 session 数据放入 JWT,服务端不需要保存 session 信息,那么服务端自然是无状态的,可以随意扩展。 看上去的确带来了扩展上的便利,但实际上没啥优势,服务器端保存