[android-developers] Re: WebView + Cookie Problem

2009-10-24 Thread Randall

that's correct.  The server rejects the session cookie and I have to
login, but the same session cookie works fine when used with other
messages to the server.  The odd thing is that this doesn't happen all
the time.  The cookie will occassionally work in the given code
snippet so I thought it might be a timing issue with how I'm calling
sync()

On Oct 23, 1:21 pm, Jason Proctor jason.android.li...@gmail.com
wrote:
 i use this mechanism and it works for me.

 do you log out what's going on in this section and see if anything
 untoward is happening?





 I have a server that sends my android app a session cookie used for
 authenticated communication.  I am trying to load a WebView with a URL
 pointing to that same server and I'm trying to pass in the session
 cookie for authentication.  I am observing that it works
 intermittently but I have no idea why.  Below is the code that I'm
 using to do this.  Any help will be greatly appreciated.

             String myUrl = http://mydomain.com/;;
             CookieSyncManager.createInstance(this);
             CookieManager cookieManager = CookieManager.getInstance();
             Cookie sessionCookie =  getCookie();
             if(sessionCookie != null){
                     String cookieString = sessionCookie.getName()
 +=+sessionCookie.getValue()+; domain=+sessionCookie.getDomain();
                     cookieManager.setCookie(myUrl, cookieString);
                     CookieSyncManager.getInstance().sync();
             }

             WebView webView = (WebView) findViewById(R.id.webview);
             webView.getSettings().setBuiltInZoomControls(true);
             webView.getSettings().setJavaScriptEnabled(true);
             webView.setWebViewClient(new MyWebViewClient());
             webView.loadUrl(myUrl);

 --
 jason.vp.engineering.particle
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: WebView + Cookie Problem

2009-10-23 Thread Jason Proctor

i use this mechanism and it works for me.

do you log out what's going on in this section and see if anything 
untoward is happening?



I have a server that sends my android app a session cookie used for
authenticated communication.  I am trying to load a WebView with a URL
pointing to that same server and I'm trying to pass in the session
cookie for authentication.  I am observing that it works
intermittently but I have no idea why.  Below is the code that I'm
using to do this.  Any help will be greatly appreciated.


   String myUrl = http://mydomain.com/;;
   CookieSyncManager.createInstance(this);
   CookieManager cookieManager = CookieManager.getInstance();
   Cookie sessionCookie =  getCookie();
   if(sessionCookie != null){
   String cookieString = sessionCookie.getName()
+=+sessionCookie.getValue()+; domain=+sessionCookie.getDomain();
   cookieManager.setCookie(myUrl, cookieString);
   CookieSyncManager.getInstance().sync();
   }

   WebView webView = (WebView) findViewById(R.id.webview);
   webView.getSettings().setBuiltInZoomControls(true);
   webView.getSettings().setJavaScriptEnabled(true);
   webView.setWebViewClient(new MyWebViewClient());
   webView.loadUrl(myUrl);


-- 
jason.vp.engineering.particle

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---