Is there any way to use cookies in meteor?
I would like to have a per-machine id so I can handle license verifications.
Thanks
well, basically we used the jquery cookie plugin for that,
unfortunately there is no way to pass cookies from the server to the client directly so far (i guess you were thinking about something similar to the php cookie implementation).
i just use https://github.com/carhartl/jquery-cookie for this,
but you can also just use the builtin javascript cookie functions for that.
https://github.com/manarius/stellar/ feel free to have a look at stellar to see how we used cookies in there :)
have fun :)
manarius
I ended up solving my own question with localStorage.
There is no need for cookies in this scenario, just used localStorage to store the machine id and send it throw the Meteor.method call.
If older browsers are an issue, use localStorage.polyfill smart package.
Related
I have an app in django project which is exposed to only post method. I want to know whether it is compulsory to expose this app to other types of requests like get, put, and delete or not.
Thank you in advance
Seems improbable that a web framework wont handle a the very least GET and POST request, but if it the case, there is no point for you to have GET, PUT and DELETE endpoints indeed.
Since i'm using EAK, each time I save a model, I have an extra request method. It's more annoying then anything and I'd like to disable it. I haven't found anything in the documentation regarding this. Has anyone ever disabled it or am I stuck with it?
I may be wrong here, but this doesn't sound like a problem with Ember-App-Kit. Are you by any chance using CORS to send your requests? You say that it sends an OPTIONS request when you save a model, but you didn't mention that it sends one when it fetches a model. This makes me think that it's a preflighted request that is unavoidable if you're using CORS. We had this same issue about a month ago and we decided to ditch CORS in favor of a proxy server.
I've never used Ember-App-Kit, but it's just a build tool, so I can't imagine how it would affect your Ember-Data adapter.
I'm interested in emulating the functionality of a web browser in C++ so that I can create a wrapper for several web sites. Right now, the biggest issues with these sites are that they make heavy use of JavaScript that interacts with the HTML DOM. Thus, the simple solution of using curl to download the page, and something like RapidXML to parse its contents is out.
Next, I considered using something like v8 with curl, and that solves the issue of interpreting the JavaScript on the page nicely. However, it doesn't solve the issue of connecting the HTML DOM methods with the JavaScript; in other words, document.getElementById() would fail in v8.
Next, I considered WebKit, which seems like it's perfectly suited to emulate a web browser--after all, Chromium and Safari both utilize it in their web browsers. However, it's a little too complete. I don't need all of the rendering aspects it includes.
So, I'd be looking for some way to:
Make an SSL connection to a web site
Interpret the JavaScript on that web site in connection with the HTML DOM
Set the value of the username/passwords <input> fields with my username and password
Simulate clicking the "Submit" button by calling the formSubmit() function, from <input type="button" onClick="formSubmit()">
Handle the HTTP POST form action and the subsequent HTTP 301 and JavaScript redirects (accomplished using window.location)
Repeat 2-5 as needed
Besides what I've already considered, what other options do I have? Ideally, I'd want this to be extremely lightweight, without requiring linking to many libraries.
I'm primarily concerned with developing for Windows 7 64-bit.
Well, this sounds all too much like a brute-force program. Disregarding that, and since you don't seem to need to render any website, I think you should just fetch the file through cURL or something, then parse it, check for the form through using a regex, retrieve the form action, then make a request using the method taken from the <form> tag and whichever input you want.
Problem is, there would be no proper way to know when is it that you've logged in properly, unless you made some kind of per-site checking. This comes mainly from the fact that many sites use sessions rather than direct cookies or HTTP auth, and since you can't read from sessions directly, it is impossible for you to guess when the session has changed.
That's the most lightweight solution I can come up with right now.
Is there a way to save a cookie that is available on other site ?
For instance I have my django project on http://www.example.com and I want that django saves a cookies for a site written in PHP on http://site.Idontknow.com .
Is this possible ?
No, this is not possible. Browsers do not let you set cookies on other sites, for (hopefully) obvious security reasons.
Short answer is no.
Longer answer is that while you can't do it directly you could include a resource in your page, like an image or a small page loaded in an iframe or similar, which came from the 3rd party site which in turn set its own cookie. Not exactly secure or reliable.
I've seen various options for URL rewriting here on Stack Overflow, and other places on the web, but was curious to see if there were other options.
This is speculation, as Cookies and URL Rewriting are the big two, but technologically, I think it'd be possible to:
do some massive hackery with javascript that captures all links and submits a form with information.
track the session on the server based on IP
Both have their downsides and holes obviously.
Session variables? At work, we are not allowed to use non session-cookies without a load of permissions.
You can either maintain state through a cookie or through a query parameter. The browser needs to be able to pass data to the web server somehow and those are the only two options.
I suppose that would depend on what technology you are using. In ColdFusion you can maintain session variables without cookies.
Using a client-side database storage, such as Google Gears (sqlite) ? Html5 is expected to include one (webkit already does it).