×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Turku, Finland
    Posts
    5

    Unhappy Cookies not being sent on N8

    Hi,

    I'm having a strange problem with N8 and WRT that the cookies set by the server are not resent by the widget's new XMLHttpRequests. I've tried pretty much everything from changing the domain of the cookie, the expiration and max_ages. If I run the same URL with the Web Browser in N8, it works just fine and the cookie is being resent as it should be. The JavaScript code I'm able to reproduce this is the following:

    Code:
    var count = 0;
    // I moved this here so that the xhr would be reused (if that would resolve the issue).
    // It won't have any effect if I put it inside the function "where it should be".
    var xhr = new XMLHttpRequest();
    function init()
    {
    	(function(){
    		var callback = arguments.callee;
    		try {
    			xhr.onreadystatechange = function() {
    				if(xhr.readyState == 4)
    				{
    					alert("result: "+xhr.responseText)
    					if(count++ < 2)
    						callback();
    				}
    			}	
    			xhr.open('GET', 'http://my.server.domain:8000/api/cookie', false);
    			xhr.send(null);
    		} catch (e) {
    			alert(e);	
    		}
    	})();
    }
    The server side looks like this (Python/Django):
    Code:
    def test_cookie(request):
        response = HttpResponse('Rock on. (%s)' % (request.COOKIES.get('test_cookie'),))
        response.set_cookie('test_cookie', '123')
        return response
    The index page is the default one that comes with the WRT template in Aptana.

    Also, this trivial widget works if I put the index.html on the server and run it via the Web Browser in N8.

    What am I doing wrong here?

    Thanks a bunch!
    Mikko

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Cookies not being sent on N8

    Terve Mikko,

    I don't have Django installation, but it works with PHP backend. Actually there is one thing that is worth of checking, which is not related to cookies itself, but widget's ability to connect to network.
    Have you checked if your homescreen widgets are in online mode (widgetit online-tilaan)?if homescreen widgets are set to offline mode, then none of the widgets are able to connect to the network.

    -Ilkka

  3. #3
    Registered User
    Join Date
    Mar 2003
    Location
    Turku, Finland
    Posts
    5

    Re: Cookies not being sent on N8

    Hi,

    I've tried all of the things you suggested. The widget is able to connect to the network and sends the requests correctly and the request sent back from the server is valid in HTTP specification. When run via the Web Browser in N8 (or any desktop browser or any other phone...), the cookie gets set correctly in both calling the HTTP endpoint that sets the cookie and by using the widget from the HTTP server (just navigating to the index.html of the widget that I put there). So this says that there must be something strange from the widget's point of view.

    Every other phone model we have and supports widgets (N97, N97 Mini and even N95 8Gb) did not have any issues with this. Only the N8 model (with the latest firmware) does not set the cookie as it should.

    Since I did not get this working I had to circumvent the problem by providing a UID for each client that is stored in the local storage and it sent as a query parameter every time it needs something from the server. Ugly and unelegant but it works.

    Thanks,
    Mikko

  4. #4
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: Cookies not being sent on N8

    The reason why the same code works on the older devices could be cookie handling implementation. It has changed dramatically from Browser 7.1 to 7.2. (you can check the version from options->Help-> About application)
    You could test widget on some other phone that has browser 7.2, if the issue is reproducible.

    Unfortunately I don't have solution for this problem, but its good to know that you were able to circumvent it.

    Br,
    Ilkka

Similar Threads

  1. cookies
    By lilin1lilin in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2010-04-22, 03:28
  2. cookies
    By obandu in forum Mobile Java General
    Replies: 2
    Last Post: 2007-02-13, 09:46
  3. cookies...
    By themainman in forum General Development Questions
    Replies: 0
    Last Post: 2005-10-26, 14:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×