<?php
/**
 * Session Configuration
 */

function startSession() {
    if (session_status() === PHP_SESSION_NONE) {
        // Get domain without www
        $domain = $_SERVER['HTTP_HOST'];
        if (strpos($domain, 'www.') === 0) {
            $domain = substr($domain, 4);
        }
        
        // Session configuration
        ini_set('session.cookie_httponly', 1);
        ini_set('session.use_only_cookies', 1);
        ini_set('session.cookie_secure', 0); // Set 1 jika HTTPS
        ini_set('session.cookie_samesite', 'Lax');
        
        // Start session
        session_start();
    }
}