New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to pass custom cookie string #513
Comments
If you have access to the cookie reading it given it’s name should just work. But that’s the problem, you do not habe access to cookies of other sites apart of your own. Only subdomains of your own domain may work, with an appropriate So are you talking about subdomains here? |
I'm having different iframes from different sites, (same domain, multiple subdomain). I'm accessing the iframe though contentDocument and I need to parse those cookies. |
Including js-cookie in those pages served by the iframes should give you the ability to retrieve these cookies, using If you have no control over these I‘m not sure how you could make use of the library. It all relies on a document.cookie of the current site. Maybe there was a way to bend the context (using |
Anyway, this seems to be more of a feature request, we might not need to look for workarounds. |
I cannot include js-cookie there. I'm already having my working code but I'm parsing these cookies by hand and wanted a cookie parser library instead. Yes, it's a feature request. |
You could use https://github.com/jshttp/cookie for parsing? |
What I want to avoid is having multiple libraries in my bundle doing cookie parsing. No offense but let me ask, why don't you use it also? :) |
It does a lot more things than we need and we strive for keeping this library as small as possible, and free of dependencies. For the same reasons it’s unlikely we’re going to implement this feature any time soon (unless suddenly a lot more people start asking for it). But since you asked for a “parser library” I thought that other one might be of help. |
The lib is coupled to However, right now js-cookie purpose is "A simple, lightweight JavaScript API for handling browser cookies". Focus on the "browser" part, which is supposed to imply a wrapper over This discussion is less about introducing a feature, but fundamentally changing the purpose of the library for the intention to satisfy one use case. I think we should wait for more requests like this with different use cases instead of jumping the gun and completely changing the purpose of the lib. However, in the meantime feel free to fork the project and extend for your own use case. Your feedback is definitely appreciated, for it helps to build up an idea of the interest on having different kinds of input parsing implemented. Who knows, we might get it implemented in v4 :) |
On a sidenote, @Krinkle does Wikipedia uses js-cookie on any of the bundles you specified in this post: https://phabricator.wikimedia.org/phame/live/7/post/175/wikipedia_s_javascript_initialisation_on_a_budget/ I remember you were active on jquery-cookie in the beginning. It's interesting to understand the codebases at scale that use js-cookie and that are also impacted with the amount of "nice to have" features we add to the payload size. |
@wintercounter Consider trying https://github.com/theodorejb/es-cookie. It has a native |
@FagnerMartinsBrack Hi. Wikipedia still uses the older and simpler jquery-cookie script (source code) with a light wrapper for application-specific integration (source code). I'm not aware of any additional features being needed for our use cases. We have sometimes found performance regressions due to use of cookies in hot code paths. However were due to lower-level cost of reading or rewriting |
@carhartl Shall we close and wait to see if there will be more requests like this in the future? This is the first request of its kind that I remember. In the meantime, I recommend to fork js-cookie and extract the parsing code yourself if somebody needs to use the parsing code. |
Which practically is, as mentioned, es-cookie. Then there‘s #595, the outcome of which almost eliminated the amount of parsing work that‘s being done. Closing.. |
I want to parse another site's
document.cookie
.Example
The text was updated successfully, but these errors were encountered: