2013-07-14 3 views
0

양식 및 ajax 콜백을 포함하는 .module 파일을 만들었습니다.Drupal 7 ajax 및 세션

function form_registration_form($form, &$form_state) { 
     $form['registration']['email'] = array(
     '#type'  => 'textfield', 
     '#required' => TRUE, 
     '#size'  => 44, 
     '#maxlength' => '80', 
     '#attributes'=> array('placeholder' => 'Email','data-email'=>'','data-min-chars'=>'5'), 
    ); 
     $form['registration']['password'] = array(
     '#type'  => 'password', 
     '#required' => TRUE, 
     '#size'  => 44, 
     '#maxlength' => '80', 
     '#attributes'=> array('placeholder' => 'Password'), 
    ); 
     $form['registration']['submit'] = array(
     '#value'  => 'SIGN IN', 
     '#type'  => 'submit', 
     '#submit' => array('form_registration_handler'), 
     ); 
     return $form; 
} 
and in the function form_registration_handler I create a session (name it test). 
Here is the ajax menu call back function: 

function mymodule_menu() { 

    $items['ajax/innerAction'] = array(
     'title' => 'Browser Inner Action', 
     'page callback' => 'innerActionCallBack', 
     'access arguments' => array('access content'), 
     'type' => MENU_CALLBACK, 
    ); 

    return $items; 
} 

function innerActionCallBack() { 
    header('Access-Control-Allow-Origin: *'); 
    drupal_session_start(); 
    print session_id(); 
} 

이 기능은 서버에 아약스를 만들 내 page.tpl.php 파일에 사용됩니다 여기에 .module 파일의 간단한 코드입니다. 여기에서 문제는 내가 아약스를 호출 할 때, 세션 ID가 다르다는 것입니다. 브라우저를 새로 고침하고 이전에 만든 세션 테스트를 검색 할 수 없습니다. 여기에서 무슨 일이 일어나고 있는지 아십니까? 어떤 도움이라도 정말 고맙게받습니다.

답변

0

그래, 내가 대답을 알아 냈어. Drupal이 올바른 sessionID를 검색 할 수 있도록 먼저 사용자를 Drupal에 로그인해야합니다.