views:

20

answers:

1

Hi all, I have declared a structure that look like

 typedef struct
 {
     char* key;
     char* value;
 }kvPair;

and in the session structure, i declared a variable as

 struct session
 {

    char* id;
    .....  // other session variables
    kvPair* pair;
  }

Now in the session_start I have initialised the values for the pair variable and I have to access these values in /ext/mysql extension. A suggestion on how to achieve it would be greatly appreciated

A: 

I'm not sure what you're trying to do, but if you want to read data that was saved in the session e.g. through this script:

<?php
session_start();
$_SESSION["key"] = "data";

Then yes, you can use the API exposed by the session extension:

#include "ext/session/php_session.h"

Then you have these functions:

void php_session_start(TSRMLS_D); /* analogue to session_start() in userspace */
int php_get_session_var(char *name, size_t namelen, zval ***state_var TSRMLS_DC);
Artefacto
once I use that. I am able to directly access the session structure variables. For example. to access id variable, i just did PS(id) and it worked like charms. Thank you for your suggestions though!
Karthick
@Karth Just because you can, doesn't mean you should. The session extension provides an API, *use it*. If you violate the abstractions, your code will stop working when the internal structures you're accessing change in some future version.
Artefacto
@Karth Well, in the particular case of fetching the current id, doesn't seem to exist any API.
Artefacto