Set Cookies on subdomain? - cookies

I have the site blah.com. I need to set 3cookies + use google analytic. I would like to set it as www.blah.com so when i serve images (on blah.com or static.blah.com) it is cookie-less.
Is this possible? How do i do it? I am using jquery-cookies and asp.net

Simply set the domain attribute of the cookie to "www.blah.com"

Related

How to set cookies in nextjs

In my next.js project,I want to set cookies when user logs in. with document.cookies(something) it is setting cookies, but it is limiting to set only one cookie. If I give more than one cookie it is taking only the first element. In both cases I am not able to get cookie values in the pages.It is giving document is not defined error.I tried using
https://github.com/js-cookie/js-cookie,
with this I am able to set and get cookies,I am not able to secure my cookies. It will be great if you can solve this or suggest me some methods.
Thanks in advance.
I'd suggest using https://www.npmjs.com/package/nookies as it's kinda tricky to do manually.
You can't use the secure flag when your app is running on localhost unless you are running the application on https. To test if the secure flag is working, deploy the application on production or testing environment.

JSESSIONID with Java & Jetty & on multple subdomains

I use jetty with Google Guice. I init the session in this way:
HttpSession sessionRequest = request.getSession(true);
I know that the session is always created if it wasn't exist.
I also know that by default this line creates a cookie in the response with the same domain I've requested the servlet (eg. domain.com).
What should I do, If a session created - let's say - on x1.domain.com, then I'd like to redirect the user to x2.domain.com, and I want to keep the JSESSIONID created on the first domain (x1.domain.com)?
I tried to start jetty with init params where I set up the default domain to ".domain.com", but it wasn't the best (although it worked), because, I use this application on different domains (domain1.com,domain2.com, etc.).
So, what is the best way to solve this? I think the best way is to transfer the JSESSIONID somehow to the new domain. But... how? :)
Thank you

Is it possible to test out Oauth Login Authentication (Facebook, Twitter, Google) without a domain and hosting?

Is there a way without actual domain name and a hosting ?
Can we use localhost in some way ?
I am using Python and Django !
Yes, just use url shorteners to create short urls kind of "localhost:port" and then register that shortened url as the callback url for your app.
FYI: some url shorteners don't allow you to shorten "localhost:port" urls. I suggest you to use goo.gl
I have a domain name and hosting but when I need to try the Oauth Authentication, what I do is:
Modify the hosts file to map a random domain to your local ip.
For example in windows, I modify the file 'C:\WINDOWS\system32\drivers\etc\hosts' adding the following line:
127.0.0.1 www.yourdomain.com
BTW, this domain doesn't need to be registered
This is what I have found out :
It can be done, simply by using 127.0.0.1 in the callback/redirect uri
It worked and I am able to test my app on localhost.

setting cookie from subdomain that includes main domain for google analytics

Main site - www.example.com
App site - app.example.com
The cookie is created on app.example.com, but should also work for www.example.com.
setcookie("gacookie", time(), time()+31536000, '/');
Is this possible? What would be the code?
The cookie is being used to create a filter for GA that will exclude all current members of my application. The cookie is set the first time they log in. Both the main domain and the subdomain use the same GA tracking code.
Also, if another site that I visit has a cookie with the string "gacookie", will that effect the Google Analytics filter, or will it only ready cookies from the domain and subdomain it is tracking...
Here are more details on how to integrate tracking across sub/domains.
http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html

quick question: how to set *.domainname.com url in django

I know there are lots of example for how to set http://domainname.com/username
url. But how to set http://username.domainname.com url in django?
Thinking a way to have a unique url for each user as http://username.domain.com like http://garry.posterous.com/
Thanks
As the first step, you need to arrange your DNS server to serve the wildcard domain; this is completely outside Django.
When you managed to do that (i.e. dig garry.posterous.com succeeds), then simply check for the HTTP_HOST request variable in the django view routines.
see Using Subdomains with Django: http://www.rossp.org/blog/2007/apr/28/using-subdomains-django/