PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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  
2015-02-12 (5 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 119 All time: 7,889 This week: 1,209Up
Version License PHP version Categories  
jlaso-my-session 1.0.1MIT/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
Name: Joseluis Laso <contact>
Classes: 9 packages by
Country: Spain Spain
Age: ???
All time rank: 215950 in Spain Spain
Week rank: 911 Up19 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Details provided by the author  

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
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:119All time:7,889
 This week:0This week:1,209Up