1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    10
    Vote Rating
    0
    gugalicious is on a distinguished road

      0  

    Default Unanswered: Unable to send cookie after authentication

    Unanswered: Unable to send cookie after authentication


    I know this has been asked many times and it was solved by others using withCrendentials and useDefaultXhrHeader. Somehow, I still don't see the cookie being passed and I've absolutely no idea why this is happening. May be I'm missing something?

    Below is the code for log-in:

    Code:
    Ext.Ajax.request({
        url: 'http://xxx.com/PostAuthentication',
        method: 'post',
        withCredentials: true,
        useDefaultXhrHeader: false,
        params: {
            username: this.getUserName().getValue(),
            password: this.getPassWord().getValue()
        },
        success: function(result, request) {
            console.log(result);              
        },
        failure: function(response) {
            console.log(response);
        },
    });
    The above code does a post and gets the cookie and session back. After getting the cookie, I make the next call below:

    Code:
    Ext.define('Auth.store.MyStore', {
        extend: 'Ext.data.Store',
        alias: 'widget.myStore',
    
    
        requires: [
            'Auth.model.MyModel',
        ],
        config: {
            model: 'Auth.model.MyModel',
            autoLoad: false,
            proxy: {
                type: 'ajax',
                method: 'GET',
                withCredentials: true,
                useDefaultXhrHeader: false,
                url: 'http://xxx.com/GetMyValues',
                reader: {
                    type: 'json',
                    rootProperty: 'abc.xyz'
                }
            },
            listeners:
            {
                exception: function (proxy, response, operation) {
                    Ext.Msg.alert('', 'Unable to load!', Ext.emptyFn);
                }
            }
        }
    });
    The above request doesn't send the cookies. I've looked around a lot and it may be a case of same-origin policy. I'm calling these files from my localhost which is not the domain http://xxx.com/. Is this one of the reason its not making those calls?

    If its because of the same-origin policy, what will be the origin (request-headers) from ipad or iphone? I'm sure someone must have tackled this situation before.

    Please let me know if you need more info. Thanks in advance!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,004
    Answers
    3489
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This in iOS 5+?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    10
    Vote Rating
    0
    gugalicious is on a distinguished road

      0  

    Default


    yes it will be deployed in iOS5 eventually. But right now the cookie is not even being sent in a web browser.

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    10
    Vote Rating
    0
    gugalicious is on a distinguished road

      0  

    Default Solution

    Solution


    I finally solved it. There is a different proxy to be used for cors. Ajax proxy will not work. User Jsonp proxy.

    http://docs.sencha.com/touch/2-0/#!/...ta.proxy.JsonP

Thread Participants: 1

Tags for this Thread