Developers
AvantGo Channel Developer Guide

TOC PREV NEXT INDEX


Tips for debugging cookies

"Help! AvantGo is erasing my cookies for no reason!"

Occasionally, we hear from AvantGo media channel customers who think that the AvantGo Client or the AvantGo sync server has somehow erased their cookies for no apparent reason. So far, in every case we've investigated, neither the AvantGo Client nor the AvantGo sync server has ever erased a cookie unless it has been told to. That being said, it can be hard to debug cookies in an AvantGo channel, since you are not able to view them directly in any sort of file on your desktop computer. So here are a few suggestions that might help you out.

Create an add_channel link that sets a cookie, with a debug=1 flag. See Setting a cookie using a link for instructions on how to do this. Not only will this tell you the status of the cookie you are trying to add, but it will tell you about all the other cookies that exist on your channel, along with their path, domain, and expiration date. This can provide very helpful information — check both the cookie name as well as the domain and the path. Make sure you have the cookie name correct — also make sure the path and domain are correct, too. If you are setting the cookie with a /cgi-bin/ path, but trying to read it from your /avantgo/ directory, you will not see the cookie.

For example, here is a link you can create for your test channel that will add a test cookie and contains a debug=1 flag so you can see the value of all other cookies on your site.

  

<a href="https://avantgo.com/channels/_add_channel.pl

?cha_id=xxxx

&set_cookie=testcookie%3D1%3B

path%3D/%3B

domain%3D.mywebsite.com%3B

expires%3DMon,+01+Jan+2004+01:00:00+GMT

&debug=1">Test my cookies</a>

  

Note: In the above example you need to replace xxxx with your channel ID, replace .mywebsite.com with your channel domain, and make sure that the expires date is in the future.

Q: Hey, I tried cutting and pasting that link into my browser (and changed xxxx to my channel ID, changed .mywebsite.com to my domain, and set the expires date in the future), but it didn't work! What is going on?

A: As a security precaution, we only let you set a cookie and see debug information if the link comes from the same domain as your channel. That is, if your channel's domain name is mywebsite.com then the add_channel link must come somewhere from mywebsite.com as well. We only match the last two domain name pieces, though, so you can create a link from www.mywebsite.com that adds a channel at avantgo.mywebsite.com.

What this means is that you cannot just cut-and-paste the link into your browser. You need to actually publish it on your site somewhere, so the referring link checks out OK.

Q: Can I use this link to view cookies on somebody else's account?

A: No. Not unless you are able to log in to AvantGo as that user. AvantGo will only display cookie information for the account you have logged in to.

You may notice that when you view your cookies, you have a whole bunch of extra cookies you did not suspect. This is because the AvantGo Client, unlike other browsers, will keep session cookies (that is, cookies with no expiration date) around for a week. The idea being that if you normally use session cookies to log in your users, they will not have to re-enter their login information every single time they sync — just once a week.

The drawback is that many websites are setting session cookies without knowing it — ASP pages do it all the time, unless you explicitly turn session cookies off in the IIS server manager. Apache servers will set session cookies if you happen to be using mod_usertrack. In many of these cases, your server will set a new session cookie every time a user syncs, meaning that a user who syncs twice a day will have 14 extra session cookies by the end of the week. In practice, this does not turn out to be too much of a problem (just a little inelegant), but it can be a little surprising for those not expecting it.

With all that being said, I do not recommend you rely on session cookies being around for a week, for a couple of reasons:

  1. We may decide to expire session cookies earlier if keeping them around for a week does cause problems for certain channel developers, and
  2. Even making your users re-login every week can get them complaining (trust me — I have seen the emails). Instead, just use normal cookies with expiration dates you can control — you will be much happier in the long run.

Caution: Here is another thing to watch out for: Suppose you have created your channel and you want to include a "Logout" function that erases all of your cookies. Do not include this as a link! Remember, the AvantGo sync server spiders through your whole channel every time a user syncs. If you include a "Logout" link that erases all your cookies, the AvantGo sync server will follow it and erase all of your cookies every time you sync!

Tip: In order to create a "Logout" function that erases all of your channel's cookies, make it into a form submission. The AvantGo sync server will not process the form request until the user clicks on the "Submit" button.



TOC PREV NEXT INDEX