# cPanel "CI_Session_driver not found" Error - IMMEDIATE FIX

**Error**: Class "CI_Session_driver" not found
**Location**: Session_driver.php line 49

---

## ⚠️ CRITICAL: This error means files weren't uploaded correctly OR PHP can't parse them

---

## 🚀 IMMEDIATE SOLUTION

### Option 1: Re-upload ENTIRE Session Directory (RECOMMENDED)

Upload the **complete** Session directory to cPanel:

**From Local**:
```
C:\xampp\htdocs\pos\system\libraries\Session\
```

**To cPanel**:
```
/public_html/system/libraries/Session/
```

**Required Files (ALL of them)**:
```
Session/
├── Session.php
├── Session_driver.php
└── drivers/
    ├── Session_database_driver.php
    ├── Session_files_driver.php
    ├── Session_memcached_driver.php
    └── Session_redis_driver.php
```

**Upload Method**:

**Via cPanel File Manager**:
1. Login to cPanel
2. File Manager → `public_html/system/libraries/`
3. **Delete** the old `Session` folder completely
4. Upload → Select your local `Session` folder
5. Extract if uploaded as ZIP

**Via FTP**:
1. Connect via FTP client (FileZilla)
2. Navigate to `/public_html/system/libraries/`
3. **Delete** old `Session` folder
4. Upload entire `Session` folder from local

---

### Option 2: Verify File Permissions

Sometimes cPanel blocks file reading due to permissions.

**Fix Permissions**:
1. cPanel → File Manager
2. Navigate to `/public_html/system/libraries/Session/`
3. Right-click `Session` folder → Change Permissions
4. Set to **755** (read/execute for all)
5. Check "Recurse into subdirectories"
6. Apply

**Individual File Permissions**:
- Session.php: **644**
- Session_driver.php: **644**
- All driver files: **644**

---

### Option 3: Check PHP Version Compatibility

**Issue**: PHP 8.3 might have issues with CodeIgniter 3

**Fix**:
1. cPanel → "Select PHP Version" or "MultiPHP Manager"
2. Change to **PHP 8.1** (most stable for CodeIgniter 3)
3. Avoid PHP 8.3 for now
4. **Recommended**: PHP 8.1.x

---

## 🔍 VERIFICATION STEPS

### Step 1: Check File Exists on Server

Via cPanel File Manager:
```
/public_html/system/libraries/Session/Session_driver.php
```

Should exist and be readable.

### Step 2: Check File Contents

Open `Session_driver.php` in cPanel editor:
- Line 49 should show: `abstract class CI_Session_driver implements SessionHandlerInterface {`
- No weird characters or encoding issues
- File should be UTF-8

### Step 3: Check Error Logs

cPanel → Errors (if available) OR check:
```
/public_html/application/logs/log-YYYY-MM-DD.php
```

Look for more specific error messages.

---

## 🛠️ ALTERNATIVE FIX: Download Fresh CodeIgniter

If files are corrupted or incomplete:

1. Download CodeIgniter 3.1.13: https://github.com/bcit-ci/CodeIgniter/archive/3.1.13.zip
2. Extract locally
3. **ONLY upload** the `system/libraries/Session/` folder to cPanel
4. Overwrite existing files

**Why**: Ensures you have uncorrupted, complete Session library files.

---

## ⚙️ CONFIGURATION CHECK

### Verify Session Configuration

**File**: `application/config/config.php`

Find session configuration (around line 380-430):

```php
$config['sess_driver'] = 'database'; // or 'files'
$config['sess_cookie_name'] = 'ci_session';
$config['sess_samesite'] = 'Lax';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions'; // table name for database driver
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
```

**If using database driver**, verify table exists:

```sql
SHOW TABLES LIKE 'ci_sessions';
```

Should return the table. If not, create it:

```sql
CREATE TABLE IF NOT EXISTS `ci_sessions` (
    `id` varchar(128) NOT NULL,
    `ip_address` varchar(45) NOT NULL,
    `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
    `data` blob NOT NULL,
    KEY `ci_sessions_timestamp` (`timestamp`)
);
```

---

## 🐛 DEBUGGING STEPS

### Enable More Detailed Errors

**Temporarily** edit `index.php` on cPanel:

Change line 36 (development section):
```php
case 'development':
    error_reporting(E_ALL); // Show ALL errors
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1); // Add this
break;
```

Visit your site and check for more specific error messages.

**IMPORTANT**: Change back to production mode after debugging!

---

## 📋 CHECKLIST

- [ ] Deleted old Session folder on cPanel
- [ ] Uploaded complete Session folder from local
- [ ] Verified Session_driver.php exists on server
- [ ] Checked file permissions (755 folder, 644 files)
- [ ] Verified PHP version is 8.1 (not 8.3)
- [ ] Checked session configuration in config.php
- [ ] Verified ci_sessions table exists (if using database driver)
- [ ] Cleared browser cache
- [ ] Tried accessing site again

---

## 💡 MOST COMMON CAUSES

### 1. Incomplete File Upload (80% of cases)
**Solution**: Delete and re-upload entire Session folder

### 2. Wrong File Permissions (15% of cases)
**Solution**: Set folders to 755, files to 644

### 3. PHP Version Issues (5% of cases)
**Solution**: Use PHP 8.1 instead of 8.3

---

## ❌ IF STILL NOT WORKING

### Last Resort: Switch to Files Driver

**Temporary workaround** if database sessions causing issues:

**Edit**: `application/config/config.php`

```php
// Change from:
$config['sess_driver'] = 'database';
$config['sess_save_path'] = 'ci_sessions';

// To:
$config['sess_driver'] = 'files';
$config['sess_save_path'] = APPPATH . 'cache/sessions/';
```

**Create directory**:
```
/public_html/application/cache/sessions/
```

**Set permissions**: 777 (writable)

This bypasses database session issues as a temporary fix.

---

## 📞 NEED MORE HELP?

Provide these details:
1. PHP version on cPanel (cPanel → Select PHP Version)
2. Output of file listing: `/public_html/system/libraries/Session/` (screenshot)
3. Contents of error log: `/application/logs/log-YYYY-MM-DD.php`
4. Session driver setting from `config.php`

---

**Quick Reference**:
- **File missing**: Re-upload Session folder
- **Permission denied**: Change to 755/644
- **Still errors**: Try PHP 8.1 or files driver

**Last Updated**: 2025-11-20
