Tag: PHP
-
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…
-
Sending Email from PHP
I remember one of my first paid programming gigs, it was to build a contact form for a friend’s website. Not one of those janky mailto: hacks that attempted to open the local email client. I’m talking about a form that would send mail from the server, you know, in…
-
Password Hashing Techniques in PHP
This post started as part of yesterday’s post on encrypting passwords as a subsection labeled “Salt? Pepper? When did this become a cooking blog?” The fact is, I felt that the section was a bit long-winded and warranted a dedicated post. Without further ado let’s talk about some techniques for…
-
Encrypting Passwords in PHP
Not all hashing functions are created equally, some are considered more secure than others and yet all of them are more secure than storing plaintext passwords. In this post I’m going to discuss some of the common PHP hashing functions that can be used as an alternative to storing plaintext…
-
Specifying a User Agent when using file_get_contents() in PHP
I recently encountered a scenario where one of my site’s login system stopped working. The piece of code that stopped working was the third-party login that leveraged GitHub for the authentication. It was one of those “it worked yesterday” moments for sure. After some research, I discovered that GitHub had…
-
How to Setup a LEMP Stack on Ubuntu 12.04 LTS
Don’t get me wrong, there’s nothing wrong with a good ol’ LAMP stack (Linux, Apache, MySQL and PHP) but in my experience, Apache doesn’t necessarily scale all that well with PHP. It’s really not Apache’s fault, the fact is that most of the time servers are configured to use the…