What potential issues could arise when using session variables in a URL shortener application in PHP?

One potential issue that could arise when using session variables in a URL shortener application is that session IDs can be exposed in the URL, making them vulnerable to session hijacking attacks. To solve this issue, you can use session cookies instead of passing session IDs in the URL.

// Start session
session_start();

// Set session cookie parameters to prevent session ID in URL
session_set_cookie_params(0, '/', '', true, true);

// Use session variables as needed
$_SESSION['user_id'] = 123;