What are some common issues with session handling in PHP applications?

Issue: Session fixation attack occurs when an attacker sets a user's session ID to a known value, allowing them to hijack the session. To prevent this, regenerate the session ID after a successful login.

// Regenerate session ID after successful login
session_regenerate_id(true);
```

Issue: Session hijacking can happen when an attacker steals a user's session ID to impersonate them. To mitigate this, store additional information in the session data, such as user agent and IP address, and verify it on each request.

```php
// Store user agent and IP address in session data
$_SESSION['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['user_ip'] = $_SERVER['REMOTE_ADDR'];

// Verify user agent and IP address on each request
if ($_SESSION['user_agent'] !== $_SERVER['HTTP_USER_AGENT'] || $_SESSION['user_ip'] !== $_SERVER['REMOTE_ADDR']) {
    // Handle invalid session
}
```

Issue: Session data can be vulnerable to tampering if not properly secured. Encrypting the session data can prevent unauthorized access and modifications.

```php
// Encrypt session data
function encryptData($data) {
    // Implement encryption logic here
    return $encryptedData;
}

function decryptData($data) {
    // Implement decryption logic here
    return $decryptedData;
}

// Store encrypted session data
$_SESSION['user_data'] = encryptData($userData);

// Retrieve and decrypt session data
$userData = decryptData($_SESSION['user_data']);