Posts Tagged ‘remains’

How to Delete Cookies?

Tuesday, July 29th, 2008

One thing you may have noticed if you have started writing Javascript to use cookies is that there is no actual delete command that can be used to delete a cookie after you have created it. This doesn’t mean that you can’t delete cookies, it just means that you need to understand how cookies work in order to be able to control when the system will delete them for you.

When you create a session cookie it will continue to exist for as long as the browser remains open and will be deleted as soon as the browser is closed. This is because session cookies are actually retained in memory by the browser and are never actually stored anywhere. You do not specify an expiry date when creating a session cookie.

If you want a cookie to last for a longer (or shorter) time than you get wioth a session cookie you need to create a first party cookie instead. With a first party cookie the cookie is actually stored in a file on your visitor’s hard drive. You specify an expiry date/time when creating a first party cookie that defines how long the cookie is to be retained on the hard drive. The cookie isn’t necessarily deleted when that date/time is reached but cookies that have passed their expiry date/’time are ignored and so as far as the browser is concerned they don’t exist.

So how does this help us if we decide that we need to delete a cookie befre the date/time that it is set to expire? Well the solution is quite simple, we change the expiry date of the cookie so that it will be considered to have already expired. Rather than having to remember what to do each time, let’s just create a small function for deleting whichever cookie that we want.

function del_cookie(name) {
document.cookie = name +
‘=; expires=Thu, 01-Jan-70 00:00:01 GMT;’;
}

Now all we need to do is to call this del_cookie() function passing it the name of whatever cookie it is that we wish to delete. The function will update the expiry date on the cookie to one long in the past so that the cookie will be considered to be expired and will be ignored by the browser exactly the same as if it didn’t exist.

Why choose that particular date for setting the expiry date to delete the cookie? Well it just happens that all of the date processing within Javascript sees the 1st January 1970 as its starting date and actually records all date/times internally as the number of milliseconds from midnight on that day. Using that date therefore is effectively equivalent to setting the expiry to zero which means that the cookie will be deleted even if your visitor has the date on their computer set incorrectly. Were we to choose a more recent date it would be possible (although very unlikely) that one of our visitors might have their computer date set incorrectly to one earlier than the exipry that we chose and so our attempt to delete the cookie wouldn’t then work for them.

Colocated Hosting

Thursday, June 26th, 2008

You have decided that a dedicated server offers the best features for your online presence. There is no need to share resources and you can set up the server as you please. There remains just one question: Are you going to rent or buy your server? Dedicated hosting means that you are renting a server from a web host. But you also have the option of buying your own server and having the host provide the facilities to house it and connect it to the Internet. This service is called colocated hosting.

The advantages of colocating include all the advantages of dedicated hosting – you have the resources of the entire server and bandwidth to do with as you please. The additional benefit over dedicated hosting is the lower cost. Because you own the server, your monthly fees don’t include charges for hardware maintenance and upkeep. On the other hand, your initial outlay will be larger because you have to buy the server. If the server is good quality and remains in service for a reasonable length of time, however, your overall costs will be lower with colocation.

The cost of colocation depends on the amount of space your server occupies. Data centers house servers in racks that in turn are housed in cabinets. Cabinets are usually 40 rack units in height, with each rack unit equal to 1.75′. The cases of server computers are measured in rack heights – 1U = 1.75′. Typical sizes for servers are 1U, 2U and 4U, so the physical size of your server will determine how much the colocation host will charge per month. Bandwidth is another factor affecting price.

There are several options available when purchasing a server and getting it to the colocation data center. If you live in close proximity to the data center you could buy a server locally and set it up at your own premises. Once it is setup you can personally deliver it to the data center. Another option is to buy the server from a mail order retailer and have them deliver it directly to the data center. This is a good option if you are not located near the data center. It saves you the cost of shipping the server and the retailer will be responsible if the server happens to be damaged in transit.  The disadvantage is that you have to set up the server remotely through a web interface. The third option is to buy the server direct from the host. Not all hosts are in the business of selling servers, but those that do may offer financing and setup assistance.
Colocation or Dedicated?

Colocation puts you in charge of the hardware, but that also means that you are responsible in the case of hardware failure. If you have signed up for dedicated hosting you are renting the server, so the host will replace hard drives or CPUs if they malfunction. The initial costs of colocation are much higher than dedicated hosting. You have to buy the server as well as insurance and software licences. All that is included in a dedicated hosting plan. Hardware upgrades are also more expensive with colocation because you have to buy the new equipment outright and pay to have it installed. Dedicated hosting plans usually allow you to upgrade either hardware or bandwidth at a reasonable cost.

The main advantage of colocation is the lower monthly costs when compared with dedicated hosting plans. Other advantages include greater control over network configuration and more flexibility. A colocation provider has to be chosen carefully. After all, they will host both your hardware and your data. Consider such details as security, network redundancy, protection from fire and earthquakes, and backup generators in the case of power outages.