Cookie Support and Usage

There may be times when you would like to have a web visitors local forecast automatically display whenever they return to your HAMweather pages.  This can be done using HAMweather's cookie support.

The process of using cookies with HAMweather is quite simple.  FIrst the cookie will need to be set on the users computer (requires a browser that supports cookies, such as Netscape or MS Internet Explorer) and then whenever the user browser the hamweather.cgi without the 'forecast' parameter being set HAMweather will use the cookie information to display the forecast.

Setting the Cookie

The process of setting a HAMweather cookie on the users system is to add the 'sc' parameter to the url of the wanted forecast (or to a form as a form element).  For example, to display the forecast for Roanoke, VA and set a cookie for this on the users system, the URL would look similir too:

The 'sc' parameter can be set to one of 5 values that offer alternatives on what exactly is stored in the cookie:

sc=0 (or parameter not used) : No cookie stored
sc=1 : cookie stored without the user and theme parameters (normal default when saving a cookie)
sc=2 : cookie stored with the user parameter but not the theme parameter
sc=3 : cookie stored with the theme parameter but not the user parameter.
sc=4 : cookie stored with both the user and theme parameters

Caution should be taken, not to add the 'sc' (BTW 'sc' stands for Set Cookie) parameter to all URLs, but to only to the URL that links to the needed forecast.  This is because, HAMweather will overwrite any previously set HAMweather cookie.  The best method to set cookies would be to offer a link on the forecast page that states something similar to :" Click here to make this forecast your default"  Then whenthe user clicks the link, HAMweather will set the cookie.  This is the method that is used in the HAMweather demo site pages included in the HAMweather package.

The following parameter information is stored in the cookie on the users system  and is used when deriving the forecast:

Using Cookies to Derive Foreast

So when does HAMwetaher use the cookie info to derive a forecast?

Anytime the hamweather.cgi is accessed without the 'forecast' parameter being set.   Normally, if the 'forecast' parameter is set, either in the URL or in a form, HAMweather will use this to derive the forecast.  If the 'forecast' parameter was not set, then HAMweather will use the cookie informations stored on the userscomputer.   If by chance, no HAMweather cookie is stored on the users system, then HAMweather will use the defaults set in the web based administration to derive the forecast.

If you plan on allowing the use of cookies with HAMweather, you sohuld set the HAMweather defaults to the forecast you want displayed when no cookie is present.

Then always link web users directly to the hamweather.cgi without setting the 'forecast' parameter. For example:  You can link directly to the hamwetaher.cgi with  an URL similar to:

HAMweather also provides the ability to override the forecast parameter in a cookie. To do this you use the 'forcefc' parameter.  Remember that you can not provide the 'forecast' parameter directory when trying to display a users default forecast. So if you want to use the users cookie but display a different forecast type you set link to the hamweather.cgi as stated earlier but also provide the forcefc parameter as in:   Where xxxxx is the forecast type to display.

Using the 'forcefc' parameter you could do things such as provide a "My weather page" that has direct links to the users forecast, state warnings, watches, shortterm forecast and more.

Well thats all there is to using cookies with HAMweather.