Skip to content

DOCSP-45065: sessions documentation#3254

Merged
rustagir merged 4 commits intomongodb:5.xfrom
rustagir:DOCSP-45065-http-sessions
Jan 29, 2025
Merged

DOCSP-45065: sessions documentation#3254
rustagir merged 4 commits intomongodb:5.xfrom
rustagir:DOCSP-45065-http-sessions

Conversation

@rustagir
Copy link
Copy Markdown
Contributor

@rustagir rustagir commented Jan 27, 2025

https://jira.mongodb.org/browse/DOCSP-45065

Adds documentation for HTTP Sessions

Staging

Checklist

  • Add tests and ensure they pass

@rustagir rustagir requested a review from a team as a code owner January 27, 2025 18:01
@rustagir rustagir requested a review from norareidy January 27, 2025 18:01
@github-actions github-actions Bot added the docs label Jan 27, 2025
@rustagir rustagir requested a review from GromNaN January 27, 2025 18:05
Copy link
Copy Markdown
Contributor

@mongoKart mongoKart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

straight 🔥

lgtm w/ a couple suggestions

Comment thread docs/sessions.txt Outdated
Comment thread docs/sessions.txt Outdated
Comment thread docs/sessions.txt Outdated
Comment thread docs/sessions.txt Outdated
Copy link
Copy Markdown
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the index creation snippet is more adapted to Laravel.

Comment thread docs/sessions.txt Outdated
Comment on lines +85 to +90
.. code-block:: sh

db.sessions.createIndex(
{ "expiry_field": 1 },
{ expireAfterSeconds: 0 }
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Laravel way to create this index is to use the Schema builder.

Schema::create('sessions', function (Blueprint $collection) {
    $collection->expire('expiry_field', 0);
});

@rustagir rustagir merged commit 867731c into mongodb:5.x Jan 29, 2025
Comment thread docs/sessions.txt
.. code-block:: php

Schema::create('sessions', function (Blueprint $collection) {
$collection->expire('expiry_field', 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the actual field name, not the name of the option that contains the field name.
Since people would not customize the field names, this will prevent them from creating a useless index without noticing.

       $collection->expire('expires_at', 0);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! as i understand, this is the name of the field that is stored in the session documents?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants