Category: Software Development
-
Getting a User’s IP Address in PHP
Getting the IP address of a user seems like a pretty trivial task but you can’t always rely on $_SERVER[‘REMOTE_ADDR’]. The super global value is the most reliable source because it is extracted directly from the TCP stack but if you’re behind a load balancer that address would be that…
-
PHP Redis Clients
In a previous post I’ve talked about installing phpredis a PHP Extension for Redis that has to be compiled from source. But what if you’re hosting scenario doesn’t allow you to compile extensions? Well you’re in luck, in addition to the extension, there are additional client libraries out there for…
-
SQLite as a PHP Session Handler
Now that I’ve discussed the in-memory data stores (NoSQL if you will) let’s switch gears to a more traditional RDBMS. SQLite by definition is a software library that implement a self-contained server-less, zero-configuration, transactional SQL database engine. It’s more important claim to fame is that it is the most widely…
-
Redis as a PHP Session Handler
Redis is one of my favorite key-value stores, the range of data types alone make it a must have in any developer”s tool belt. Another great use for Redis is as your session handler in PHP. The optional persistence that Redis provides makes it a better option than using Memcached…
-
Memcached as a PHP Session Handler
Memcached makes a semi-perfect solution for storing your PHP sessions. Why only semi-perfect? Well in Memcached’s defense, the fact that it is an in-memory data store makes it a great choice because of the speed. The negative is the lack of persistence, which makes it somewhat less desirable. What this…
-
Installing PHP Redis – A PHP Extension for Redis
Redis is one of my favorite new data stores of the NoSQL movement. It has the power and speed to act as a caching server like Memcached and it has more advanced data types to make it more like an RDBMS. Before we can talk about using Redis as a…
-
Calculate Age from Date with PHP
Calculating the age based on a date is a pretty simple task that can be accomplished many different ways (Google yield’s quite a few different approaches). The caveat that usually arises is that you need to factor in which side of the birthday you are on based on the day’s…
-
Configuring PHP Sessions
Now that we know how to use sessions and have built a simple login system, let’s take a look at some options for configuring PHP sessions. Out of the box, PHP is configured to file-based sessions with a max lifetime of 1440 seconds (a mere 24 minutes). Garbage collection probability…
-
PHP Login System
Following up on yesterday’s introduction to PHP Sessions, let’s talk about building a simple login system in PHP. To start, you will need to make sure that pages on your site that are behind the login page will have sessions enabled. This can be done for all of your pages…
-
PHP Session Handling
Sessions, one of those necessary evils when building websites. They come into play whenever you need to have data available between pages on a site. These scenarios typically arise when you have login restricted areas on a site. Why do I refer to them as evil? Quite a few reasons…