<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga" -->

---
title: Scheduled Session Garbage Collection in Laravel 13.39
description: Laravel 13.39.0 adds a session:garbage-collect Artisan command so session cleanup can run on a schedule instead of relying on random request lottery. The...
canonical: https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Scheduled Session Garbage Collection in Laravel 13.39 | daily.dev
og:description: Laravel 13.39.0 adds a session:garbage-collect Artisan command so session cleanup can run on a schedule instead of relying on random request lottery. The...
og:url: https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga
og:image: https://api.daily.dev/og/posts/skEvw5rgA.png
og:image:alt: Scheduled Session Garbage Collection in Laravel 13.39
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Scheduled Session Garbage Collection in Laravel 13.39

**[Laravel News](https://daily.dev/sources/ln)** · 8 min read · 1 upvotes · 0 comments

## Summary

Laravel 13.39.0 adds a session:garbage-collect Artisan command so session cleanup can run on a schedule instead of relying on random request lottery. The release also lets models disable their primary key via #[Table(key: false)], adds a duration property (in milliseconds) to the JobAttempted event, and adds min/max/between/exactly size methods to Rule::array(). Config, route, and event cache files now write atomically to a temp file and rename it, fixing a bug where OPcache could serve an empty cache file until PHP-FPM restarted. Several testing helpers were also fixed, including a new WithoutMigrationEvents attribute and mail fake support for html() and plain().

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://laravel-news.com/laravel-13-39-0>

## Questions this post answers

### How do I run Laravel session garbage collection on a schedule instead of randomly?

Laravel 13.39 adds a session:garbage-collect Artisan command that runs the session driver's garbage collector on demand. Schedule it with Schedule::command('session:garbage-collect')->hourly(), using your session.lifetime value to determine expired sessions. To stop the random per-request cleanup from also running, set the lottery option in config/session.php to [0, 100].

_Developers tuning session cleanup can track Laravel scheduler changes like this on daily.dev._

### How do I disable the primary key on an Eloquent model in Laravel?

Use the #[Table(name: 'activity_log', key: false)] attribute on the model class, which Laravel 13.39 added support for. Previously a null key fell back to the default $primaryKey property of 'id', requiring you to still define it. A follow-up fix also marks these models as non-incrementing so create() no longer throws after insert.

_Those modeling keyless tables in Eloquent can follow framework changes like this on daily.dev._

### Why did my PHP-FPM app fail on every request after running config:cache?

With opcache.validate_timestamps=0, OPcache could cache an empty config, route, or event cache file if a request booted while the cache command was still writing it, causing every subsequent request to fail until PHP-FPM restarted. Laravel 13.39 fixes this by writing cache files to a temporary file and renaming it atomically.

_Teams debugging flaky deploy-time outages can watch for framework fixes like this on daily.dev._

## Similar posts on daily.dev

- [Storage Cache Store in Laravel 13.10.0](https://daily.dev/posts/storage-cache-store-in-laravel-13-10-0-r1lc1xf37) · Laravel News · 35 upvotes · 4 comments
- [Scheduler Attributes and Listener Discovery Control in Laravel 13.12.0](https://daily.dev/posts/scheduler-attributes-and-listener-discovery-control-in-laravel-13-12-0-msgobr9oc) · Laravel News · 9 upvotes · 1 comments
- [Tagged Memoized Cache and Model Refreshes in Laravel 13.33](https://daily.dev/posts/tagged-memoized-cache-and-model-refreshes-in-laravel-13-33-q4woi8bpl) · Laravel News · 9 upvotes · 2 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#php](https://daily.dev/tags/php), [#authentication](https://daily.dev/tags/authentication), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Scheduled Session Garbage Collection in Laravel 13.39","url":"https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga"},"datePublished":"2026-10-28T13:29:49.893Z","dateModified":"2026-10-28T15:01:37.912Z","description":"Laravel 13.39.0 adds a session:garbage-collect Artisan command so session cleanup can run on a schedule instead of relying on random request lottery. The...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ee40e2048594e45913dd31bd66f36e1c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ee40e2048594e45913dd31bd66f36e1c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Laravel News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Laravel News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ln","url":"https://daily.dev/sources/ln"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,php,authentication,laravel","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Laravel News","item":"https://daily.dev/sources/ln"},{"@type":"ListItem","position":3,"name":"Scheduled Session Garbage Collection in Laravel 13.39"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/scheduled-session-garbage-collection-in-laravel-13-39-skevw5rga#faq","mainEntity":[{"@type":"Question","name":"How do I run Laravel session garbage collection on a schedule instead of randomly?","acceptedAnswer":{"@type":"Answer","text":"Laravel 13.39 adds a session:garbage-collect Artisan command that runs the session driver's garbage collector on demand. Schedule it with Schedule::command('session:garbage-collect')-\u003ehourly(), using your session.lifetime value to determine expired sessions. To stop the random per-request cleanup from also running, set the lottery option in config/session.php to [0, 100]. Developers tuning session cleanup can track Laravel scheduler changes like this on daily.dev."}},{"@type":"Question","name":"How do I disable the primary key on an Eloquent model in Laravel?","acceptedAnswer":{"@type":"Answer","text":"Use the #[Table(name: 'activity_log', key: false)] attribute on the model class, which Laravel 13.39 added support for. Previously a null key fell back to the default $primaryKey property of 'id', requiring you to still define it. A follow-up fix also marks these models as non-incrementing so create() no longer throws after insert. Those modeling keyless tables in Eloquent can follow framework changes like this on daily.dev."}},{"@type":"Question","name":"Why did my PHP-FPM app fail on every request after running config:cache?","acceptedAnswer":{"@type":"Answer","text":"With opcache.validate_timestamps=0, OPcache could cache an empty config, route, or event cache file if a request booted while the cache command was still writing it, causing every subsequent request to fail until PHP-FPM restarted. Laravel 13.39 fixes this by writing cache files to a temporary file and renaming it atomically. Teams debugging flaky deploy-time outages can watch for framework fixes like this on daily.dev."}}]}
```

