Skip to content
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

Cookies missing? #25

Open
dnd opened this issue Jul 12, 2010 · 4 comments
Open

Cookies missing? #25

dnd opened this issue Jul 12, 2010 · 4 comments

Comments

@dnd
Copy link

dnd commented Jul 12, 2010

I'm trying to access cookies that are set by my application in some js, but envjs does not seem to be aware of them. I checked the cookies on both request and response side in rails and the data is there as it should be. The cookies work fine in the browser, and through selenium, so not sure what the disconnect is with envjs. My site does use subdomains, but I don't know if that makes any difference given that the behavior works as expected in other places.

@smparkes
Copy link
Owner

Do you have an example of this? envjs does have some cookie support, but as you mention, there may be holes.

@dnd
Copy link
Author

dnd commented Aug 21, 2010

Not sure how best to show the example I have as it's made up of a lot of small pieces of code in multiple places.

I'm using capybara with cucumber(the scenario is tagged with @javascript), and as mentioned my app makes use of subdomains. So things go kind of like this:

When a request is made through cucumber I set the following:
Capybara.default_host = "#{subdomain}.myappdomain.local"
Capybara.app_host = "http://#{subdomain}.myappdomain.local" if Capybara.current_driver == :envjs

A user is then logged in, and at this point the Rails code sets a cookie named "current_person" containing the user information.

I then go to a page and perform some action that needs to make use of the cookie such as 'click_link "Add Me"'. This action will then trigger code using the jquery.cookie plugin to execute:

var cookie = $.cookie("current_person");

after this call, 'cookie' is null and the subsequent javascript operation fails because it's expecting that to not be null. As mentioned the exact same code works fine through my own use of the browser, as well as selenium.

It's been a while since this happened, and I had to work around it and move past it so I'm sorry I'm not super sharp on the details. I do need to get it working ultimately, so if there's more information you need let me know and I'll start trying to dig back into it.

I'm fairly certain the problem has something to do with my use of subdomains. One thing that I seem to recall before was a difference in the cookie domain being used. I think it was that the cookie was being written when envjs was in use without the subdomain, so it was just at the root myappdomain.local, and selenium and regular browsing would write the cookie at smithco.myappdomain.local. Either that or I found out that the cookie was being lost. Hopefully this gives you something to go on, let me know what else I can provide.

@smparkes
Copy link
Owner

Okay.

I'll see if I can track it down. It could take me some time to get to it. I'm not that familiar with the cookie code in envjs either. I've touched it on occasion, but minimally.

@smparkes
Copy link
Owner

smparkes commented Sep 2, 2010

At this point, I don't think I'm going to be able to look at this without a test that I can easily reproduce it with. Time's really tight. If you can build a test, or want to jump in yourself ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants