PHP Classes

File: README.MD

Recommend this page to a friend!
  Classes of Joseluis Laso   jlaso My Session   README.MD   Download  
File: README.MD
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: jlaso My Session
Store and get additional session data in files
Author: By
Last change: Update of README.MD
Date: 4 months ago
Size: 1,796 bytes
 

Contents

Class file image Download

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';