前言介紹
- 這款 WordPress 外掛「WordPress Native PHP Sessions」是 2014-09-23 上架。
- 目前有 10000 個安裝啟用數。
- 上一次更新是 2024-10-29,距離現在已有 185 天。
- 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 5.4 以上。
- 有 16 人給過評分。
- 論壇上目前有 1 個提問,問題解答率 0%
外掛協作開發者
stovak | jspellman | rwagner00 | getpantheon | jazzs3quence | mpvanwinkle77 | andrewtaylor-1 | danielbachhuber | outlandish-josh |
外掛標籤
內容簡介
WordPress 核心不使用 PHP sessions,但有時您的使用案例、外掛或佈景主題可能需要使用它們。
此外掛實現了 PHP 的原生 session handlers,後台由 WordPress 資料庫支援。這可讓外掛、佈景主題和自訂程式碼在 PHP 預設暫存檔無法運作的分散式環境中安全地使用 PHP $_SESSION。
請注意,如果您想要貢獻,主要開發在 GitHub 上進行:
https://github.com/pantheon-systems/wp-native-php-sessions
配置
預設會話壽命為 0,即到瀏覽器關閉為止。
要覆蓋此設定,請在 WordPress Native PHP Sessions 外掛載入之前使用 pantheon_session_expiration 過濾器。例如,一個小型的 Must-use 外掛(也稱為 mu-外掛)可能包含以下內容:
function my_session_expiration_override() {
return 60*60*4; // 4小時
}
add_filter( 'pantheon_session_expiration', 'my_session_expiration_override' );
貢獻
有關貢獻信息,請參閱CONTRIBUTING.md。
疑難排解
如果出現類似「致命錯誤:session_start():初始化存儲模塊失敗:」或「警告:ini_set():活動的 session。」的錯誤,那麼您可能有一個在 WP Native PHP Sessions 載入之前啟動會話的外掛。
若要修復此問題,在 wp-content/mu-plugins/000-loader.php 創建一個新檔案並包含以下內容:
require_once WP_PLUGIN_DIR . '/wp-native-php-sessions/pantheon-sessions.php';
這個 mu-外掛將在所有其他外掛之前加載 WP Native PHP Sessions,同時讓您仍然可以使用 WordPress 外掛更新程式來維護外掛的最新狀態。
原文外掛簡介
WordPress core does not use PHP sessions, but sometimes they are required by your use-case, a plugin or theme.
This plugin implements PHP’s native session handlers, backed by the WordPress database. This allows plugins, themes, and custom code to safely use PHP $_SESSIONs in a distributed environment where PHP’s default tempfile storage just won’t work.
Note that primary development is on GitHub if you would like to contribute:
https://github.com/pantheon-systems/wp-native-php-sessions
Configuration
By default the session lifetime is set to 0, which is until the browser is closed.
To override this use the pantheon_session_expiration filter before the WordPress Native PHP Sessions plugin is loaded. For example a small Must-use plugin (a.k.a. mu-plugin) could contain:
CLI Commands
wp pantheon session add-index
Added in 1.4.0. This command should be run if your installation of the plugin occurred before the addition of the primary ID key to the session table in version 1.2.2. You will be automatically notified when you visit any admin page if this is the case. If there’s no message, your version is good to go. Note that this command is non-destructive, a new table will be created and the existing one preserved in a backup state until you have verified that the upgrade is functioning as expected.
wp pantheon session primary-key-finalize
Added in 1.4.0. If you have run the add-index command and have verified that the new table is functioning correctly, running the primary-key-finalize command will perform a database cleanup and remove the backup table.
wp pantheon session primary-key-revert
Added in 1.4.0. If you have run the add-index command and something unexpected has occurred, just run the primary-key-revert command and the backup table will immediately be returned to being the active table.
WordPress Multisite
As of 1.4.2 the add-index, primary-key-add and primary-key-revert commands are fully multisite compatible.
Contributing
See CONTRIBUTING.md for information on contributing.
Troubleshooting
If you see an error like “Fatal error: session_start(): Failed to initialize storage module:” or “Warning: ini_set(): A session is active.”, then you likely have a plugin that is starting a session before WP Native PHP Sessions is loading.
To fix, create a new file at wp-content/mu-plugins/000-loader.php and include the following:
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WordPress Native PHP Sessions」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.5 | 0.6.0 | 0.6.1 | 0.6.2 | 0.6.3 | 0.6.4 | 0.6.5 | 0.6.6 | 0.6.7 | 0.6.8 | 0.6.9 | 0.7.0 | 0.8.0 | 0.8.1 | 0.9.0 | 1.0.0 | 1.2.0 | 1.2.1 | 1.2.2 | 1.2.3 | 1.2.4 | 1.2.5 | 1.3.0 | 1.3.1 | 1.3.2 | 1.3.3 | 1.3.4 | 1.3.5 | 1.3.6 | 1.4.0 | 1.4.1 | 1.4.2 | 1.4.3 | trunk | 0.3-alpha |
延伸相關外掛(你可能也想知道)
Akismet Anti-spam: Spam Protection 》Akismet會檢查您的評論和聯繫表單提交,將它們與全球垃圾郵件數據庫進行比對,以防止站點發佈惡意內容。您可以在部落格的“評論”管理畫面中檢查評論垃圾郵件的...。
Antispam Bee 》用 Antispam Bee 保障你的 WordPress 博客或網站免受評論垃圾郵件的困擾。這個外掛可以有效地阻止垃圾評論和引用,不需要驗證碼,也不會將個人信息發送給第三...。
Spam protection, Anti-Spam, FireWall by CleanTalk 》Forms spam filter, Plugin extends spam protection for Gravity Forms. It filters spam submissions for each form created with Gravity Forms., MemberP...。
Disable Comments 》Disable Comments Plugin 是一個供管理員完全關閉網站評論功能的工具。我們的外掛程式可以全域性地關閉所有文章、頁面和附件的評論功能,移除所有相關的功能...。
Comments – wpDiscuz 》wpDiscuz是一個具有自訂評論表單和欄位的AJAX即時評論系統,旨在加強WordPress原生評論功能。速度超快且具有數十種功能,是Disqus和Jetpack Comments的最佳替...。
Disqus Comment System 》Disqus 是網路上最受歡迎的評論系統,被數百萬的出版商信任,以增加讀者參與度、成長觀眾及流量、以及賺取內容。Disqus 協助各種尺寸的出版商直接與其觀眾互...。
Cookies for Comments 》這個外掛將會在你的部落格 HTML 的原始碼中新增一個樣式表或圖片。當瀏覽器讀取該樣式表或圖片時,會放置一個 Cookie。如果有使用者在這之後留下評論,該 Coo...。
Throws SPAM Away 》這個外掛的開發旨在打擊海外的評論垃圾郵件,目前以下的篩選器被用來判定垃圾郵件。, ・日語篩選(是否包含日語), 只有留言中包含日語字符才能被發布,沒...。
Subscribe to Comments 》Subscribe to Comments是一個強大的 WordPress 外掛,讓留言者可以訂閱文章回覆的電子郵件通知。此外掛還包括一個完整的訂閱管理工具,使留言者可以取消訂閱...。
Disable Comments 》此外掛完全禁用網站前端和後端的評論功能:, * 隱藏現有評論, * 在前端關閉評論, * 禁用評論、引用通告和Ping的支援, * 重新導向任何試圖訪問評論頁面的使用...。
Subscribe To Comments Reloaded 》Subscribe to Comments Reloaded 是一個功能強大的外掛,讓留言者可以訂閱後續評論的電子郵件通知。此外掛還包括一個完整的訂閱管理器,讓留言者可以取消訂閱...。
Post-Plugin Library 》Post-Plugin Library 是一個共享代碼庫,並沒有獨立的功能,必須安裝它才能為 Similar Posts、Recent Posts、Random Posts、Popular Posts 和 Recent Comment...。
One Click Close Comments 》使用者可以從文章管理頁面(‘編輯文章’)及頁面管理頁面(‘編輯頁面’)中,對於他們有足夠權限進行更改的文章關閉或開啟評論(基本上是管...。
No Page Comment 》直到最近,WordPress 提供兩種選擇:你可以默認禁用所有頁面和文章的評論和引用追蹤,或者你可以啟用它們。在WordPress 4.3 版本中,這種情況終於改變,所以...。
WP Social Comments 》, , WP Social(Facebook) Comments, , , WP Social (Facebook) Comments 讓使用者使用他們的 Facebook 帳戶在您的網站上進行評論,使用者可以選擇在 ...。