Error session_start() pada session.php

Pada tutorial kali ini, kami akan membahas seputar error yang terjadi pada fungsi session_start() dalam file session.php. Berikut ini contoh pada Ecommerce Abantecart yang mengalami masalah tidak dapat menemukan file atau folder untuk menyimpan session data, sehingga kita perlu memverifikasi pengaturan pada session.save_path.

Source Code (error.txt)

2016-07-13 0:12:48 - warning:  AbanteCart core v.1.1.9 session_start(): open(/tmp/sess_1b085e4ae55903762bbb0756955fb72f, O_RDWR) failed: No such file or directory (2) in <b>/home/tokotek2/public_html/core/lib/session.php</b> on line <b>78</b>
2016-07-13 0:12:48 - warning:  AbanteCart core v.1.1.9 session_start(): open(/tmp/sess_1b085e4ae55903762bbb0756955fb72f, O_RDWR) failed: No such file or directory (2) in <b>/home/tokotek2/public_html/core/lib/session.php</b> on line <b>83</b>
2016-07-13 0:12:56 - warning:  AbanteCart core v.1.1.9 session_start(): open(/tmp/sess_1b085e4ae55903762bbb0756955fb72f, O_RDWR) failed: No such file or directory (2) in <b>/home/tokotek2/public_html/core/lib/session.php</b> on line <b>78</b>
2016-07-13 0:12:56 - warning:  AbanteCart core v.1.1.9 Unknown: open(/tmp/sess_1b085e4ae55903762bbb0756955fb72f, O_RDWR) failed: No such file or directory (2) in <b>Unknown</b> on line <b>0</b>
2016-07-13 0:12:56 - warning:  AbanteCart core v.1.1.9 Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in <b>Unknown</b> on line <b>0</b>

Solusi:

Debian tidak menggunakan default garbage collector untuk sessions. Dengan demikian, it sets session.gc_probability to zero and it runs a cron job to clean up old session data in the default directory. As a result, if your site sets a custom location with session_save_path() you also need to set a value for session.gc_probability, e.g.:

<?php
session_save_path
('/home/example.com/sessions');
ini_set('session.gc_probability', 1);
?>

Otherwise, old files in '/home/example.com/sessions' will never get removed! 

Tambahkan kode berikut pada line 77 dan 78 (sebelum session_start() diekseskusi. Untuk melihat keseluruhan file session.php dapat mengakses Code GitHub


Who's Online

We have 21 guests and no members online

TMN Trending Hashtags

There are no trending hashtags at this moment.

TMN Discussions

TMN Events Calendar