Jump to content

sessions php 5.2.14 Apache windows (vertrigo)


Recommended Posts

Hello,

 

I installed the vertrigo package on Windows XP which runs php 5.12.14. I've a program that uses sessions whose data are stored in a MySql datbase. This program works fine on linux. Almost everything works on windows as well, session_start works, the write handler works. The read handler works and returns the serialized data of the session (I checked this), BUT $_SESSION is empty after session_start?

 

Any help much appreciated. Thanks.

 

Here below are the session configuration parameters and the read handler code.

 

function set_session_parameters() {

/*  ini_set('session.save_path', '/home/piet/sessions/quotes');*/

  session_name('QUOTEID');                        /* call session_name before gc parameters, should be safer*/

  ini_set('session.gc_divisor', '100');

  ini_set('session.gc_maxlifetime', '86400'); /*garbage periodicity for sessions in seconds: 1 day, this applies only to sessions with 'started' status (see _clean_session_quote()).*/

  ini_set('session.gc_probability', '35');      /*this value/divisor(default 100)=probability of launching the garbage collector on session_start(), here probability=3/10*/

  ini_set('session.use_only_cookies', '0');          // don't rely on cookies

  ini_set('session.use_cookies', '0');

  ini_set('url_rewriter.tags',''); //This is in the case the propagation of the sid in the url were enabled (session.use_trans_sid set to 1)  while it should be disabled by default.

  ini_set('session.serialize_handler','php');

  ini_set('session.save_handler','user');

  //use a data base for custom storage of the sessions

  session_set_save_handler('_open_session','_close_session','_read_session','_write_session','_destroy_session_quote','_clean_session_quote');

  }//set_session_parameters

 

function _read_session($id){

  global $dbref;

  $id = mysql_real_escape_string($id);

  $sql = "SELECT data FROM sessions WHERE id = '$id'";

  if (!is_resource($result = @mysql_query($sql, $dbref)))

    throw new Exception("can't read session:" . mysql_error());

  if (mysql_num_rows($result)){

      $record = mysql_fetch_assoc($result);

      return $record['data'];

  }

  return '';

 

}//_read_session

Link to comment
Share on other sites

I reply to myself if that can be of any help to others. I didn't manage to get the default php session serializer to work. However, as the XML wddx serializer comes bundled with the windows php version, I explicitly switched to this serializer:

  ini_set('session.serialize_handler', 'wddx');

before starting the session and things work fine.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.