开发者

Accessing Session variables in /ext/mysql extension

开发者 https://www.devze.com 2023-01-13 18:38 出处:网络
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

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 woul开发者_StackOverflow中文版d be greatly appreciated


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号