Categories
PHP

How to use PostgreSQL

PHP supports PostgreSQL, the pg_connect() function is used to connect to a PostgreSQL database server. Once a connection has been established, SQL commands can be executed with the pg_query() function.

Categories
PHP

How to use MySQLi

PHP allows developers to interact with databases in two ways: MySQLi (MySQL Improved) extension and PDO (PHP Data Objects) extension. In this tutorial we’ll discuss the MySQLi extension which provides both speed and feature benefits over the PDO version and is a good choice for MySQL (or MariaDB) specific development projects.

Categories
PHP

Configuring Sessions in PHP.INI

The configuration of PHP’s session mechanism is completely triggered in the [session] section of the php.ini configuration file. The default settings might not be suitable for all applications, so the next few codes cover some possible configurations.

Categories
PHP

Sessions Garbage Collection

How to configure PHP’s Garbage collection mechanism to remove old/expired sessions from the server.

Categories
PHP

HTTP Authentication with Sessions

The HTTP provides two methods of authentication: basic and digest. In this tutorial, we’ll discuss only “Basic” authentication method and use this method in conjunction with PHP sessions.

Categories
PHP

Creating a Secured Members Area with Sessions

Sessions are a great way to secure certain parts of your website. In this tutorial, we create a PHP script that checks the site users, redirects unauthenticated users to the login page, and after a successful authentication sends them back to the page where they came from.

Categories
PHP

Storing Sessions in Database

By default, sessions are read from files, you can use the session_set_save_handler() function to define custom session handlers to store session data in a database. In this tutorial, we’ll create two code snippets, Procedural and OOP, to manage session data.

Categories
PHP

Session Fixation: Changing Session ID

Session fixation exploits a weakness in your PHP script. Especially, if you do not generate a new session id for users when authenticating them.

Categories
PHP

Creating Sessions Without Cookies

How to use PHP sessions if the client browser does not support (or blocked) cookies?

Categories
PHP

Reading, Writing, and Removing Sessions

In this tutorial, we discuss how to use PHP sessions, showing how sessions are started and ended and how session variables are used.