PHP Classes

jlaso My Session: Store and get additional session data in files

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-06-02 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 135 All time: 9,231 This week: 102Up
Version License PHP version Categories
jlaso-my-session 1.0.8MIT/X Consortium ...5.2PHP 5, Files and Folders, User Manage...
Description 

Author

This class can store and get additional session data in files.

It can set and get values of named keys that are stored in server side files.

The class can serialize in JSON format the list of defined keys before they are stored in a file in a given directory.

It can also read a previously saved file to unserialize and return the values of previously stored keys.

The accesses to keys file is done without locking the file.

Picture of Joseluis Laso
  Performance   Level  
Name: Joseluis Laso <contact>
Classes: 16 packages by
Country: Spain Spain
Age: 55
All time rank: 92819 in Spain Spain
Week rank: 105 Up5 in Spain Spain Up
Innovation award
Innovation award
Nominee: 6x

Winner: 2x

Details

This is a complement of session files.

SensioLabsInsight

When you start an activity through ajax request and you want to get info of this activity via ajax, the subsequents requests are blocked waiting for the termination of the first request.

You need to stop using php's session file to serve more ajax request.

Sample of use:

Status.php

<?php

if (isset($_REQUEST['sid'])) session_id($_REQUEST['sid']);
session_start();

// MySession
require '../MySession/MySession.php';
$mysession = new MySession(session_id());

$id = isset($_REQUEST['id'])?$_REQUEST['id']:'';

// this sends to requester the percent of activiy and id,
// normally the requester is a javascript routine and for not
// use global id vars now this script returns id
print(json_encode(array(
                    "p"  => $mysession->readKey($id),
                    "id" => $id,
     )));

    

?>

Activity

This file is that starts the activity and controls the percentage of activity, sample:

<?php

function process_demo(){

// ..code..

$mysession = new MySession( session_id() );

$app->contentType("text/html");

$mysession->writeKey($id, 0);

// relase php session for calls from requester stay attended
session_write_close();

// .. code that process long time ..

// indicates that finishes the long action
$mysession->writeKey($id, "OK");

die();    

}

?>

In index.php bootstrap in SlimFramework project add:

// MySession require './app/others/MySession/MySession.php';

  Files folder image Files  
File Role Description
Accessible without login Plain text file MySession.php Class Class source
Accessible without login Plain text file README.MD Doc. Documentation
Accessible without login Plain text file status.sample.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:135
This week:0
All time:9,231
This week:102Up