0


I'm at the beginning adventure with programming, so please be lenient with me. ;) I stucked developing an client-server app. The problem is I cannot get or set cookie from the server side (it's in java). The user side is in javascript (angularjs) and I probably can get and set cookies correctly. (I can see the set cookie in sources and vice versa during debugging I can see that cookies are collected in javascript part).
I was searching and found many tutorials how to do this, but no of them helped me. :( I have no idea what to do, maybe there is another solution of this problem? Cookies are not passed in headers.
I need to stay authenticated in this app so the idea was: Client gives login and password, token is being made, when client side get response from server it sets cookie with value of token so it won't loose chiefly during refresh. Server check if cookie value is correct and everything is great. But nope.
I'm in trouble, please help.

aliszja
  • 21
  • 2

1 Answers1

0

Where are your fronted code loaded from? The same server as the one you log in to? If not, you probably have to consider a problem with the "same origin" policy in the browser and should perhaps consider CORS. Here is a post which I just found. AngularJS CORS Issues

Community
  • 1
  • 1
  • Fronted code is loaded from apache server, so it's probably as you said. But I don't excatly get it... I have in my javascript wrote methods to connect with server. Problem is when I want to refresh. I checked out and found that with refresh last method is being called, so if it worked once why it don't want to work once again? I just don't get it. – aliszja Oct 11 '15 at 19:21
  • OK - been a way a couple of days. Don't know if this is still relevant, but you should try to use Chrome and developer tools, if you don't do that already. Then in the network tab, watch what cookies that are sent to the server. If the cookie is there, then the problem is on the server. If the cookie is not there, then you probably need to consider the CORS issue and use $httpProvider.defaults.useXDomain = true; – Søren Pedersen Oct 18 '15 at 18:12