Cheap Web Hosting for Developers

PHP, MySQL, Java, Unix Cheap Web Hosting

128 Chapter 4 Web Application Concepts Figure 4.1

Filed under: Web Applications Development With PHP4.0 — webmaster @ 05:33

130 Chapter 4 Web Application Concepts Details on session ID propagation in real life will follow a bit later. First, we d like to show you another way of session ID propagation, arguably the most geeky method. DNS Tricks The need to tag all links in an application with the session ID can be really annoying. PHP 4.0 has a way to do it automatically, but it may be a severe performance hit on larger sites, and it doesn t work with PHP 3.0. We may have a solution for you. Up front, the caveats:You need to be able to change the DNS record for your server, and the server you want to use for this kind of session ID propagation needs its own, static IP. Name-based virtual hosting won t work here. You meet these requirements? Great. If you re proficient with name servers, you may know that wildcard entries can be used in DNS configuration.These entries usually map any arbitrary hostname to a specific IP; for example, we ve got this entry to direct requests for everything below phpwebdev.com to the IP 194.242.199.228: *.phpwebdev.com IN A 194.242.199.228 A request for http://this.is.one.cool.domain.phpwebdev.com will be redirected to the specified IP.Since the hostname is arbitrary,Apache must be configured to handle the IP as opposed to name-based virtual hosting, where the hostname must be fixed and known. Our Apache configuration looks like this: ServerAdmin tobias@dev.phpwebdev.com DocumentRoot /home/www/htdocs ServerName phpwebdev.com Our trick will also work fine if Apache s main server is bound to this address. The scope of this is of course to encode the session ID in the hostname itself. On the first request to the application, the session ID is created, and the client is redirected to the new URL containing the tagged hostname, which will look like this: 355e1bce8828d4fb5c83c1e35ad02caa.phpwebdev.com The advantage is clear:As long as you use relative links in your application,it s no longer necessary to bother with any manual URL rewriting! We have modified the earlier session start function to extract the session ID from the hostname: function session_start_from_host($host) { global $HTTP_HOST, $PHP_SELF; ereg( ([0-9a-z]{32}). , $HTTP_HOST, $regs); $session_id = $regs[1];

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by Cheap Web Hosting