function session_cache_file_session_cache_set in Session Cache API 7
Same name and namespace in other branches
- 8 session_cache_file/session_cache_file.module \session_cache_file_session_cache_set()
Implements hook_session_cache_set().
File
- session_cache_file/
session_cache_file.module, line 65 - session_cache_file.module
Code
function session_cache_file_session_cache_set($method, $bin, $data) {
if ($method != SESSION_CACHE_FILE_STORAGE_FILE) {
return;
}
$path = session_cache_file_directory($bin);
$sid = session_cache_get_sid();
if ($data == NULL) {
if (!$path || !$sid || !@unlink("{$path}/{$sid}")) {
drupal_set_message(t('Session cache file for empty session state could not be deleted.', array(
'%bin' => "{$bin}/{$sid}",
)), 'warning', FALSE);
}
}
elseif (!$path || !$sid || @file_put_contents("{$path}/{$sid}", json_encode($data), FILE_EXISTS_REPLACE) === FALSE) {
drupal_set_message(t('Session cache file for session state %bin could not be written.', array(
'%bin' => "{$bin}/{$sid}",
)), 'error', FALSE);
}
}