Session variables on custom modules I have two modules. The first module is for custom login form and the other is for custom user pages.
I want to store a session variable from the first module and later to call on the second module. 
Let's say my field from the first module is:

&lt;?php
function custom_login_form($form, &amp;$form_state) {

    $form['custom_field'] = array(
       '#type' =&gt; 'textfield',
       '#title' =&gt; 'Custom field',
    );

   return $form
} 


and this is the callback from my second module:

    &lt;?php
    function custom_user_pages() {
       $The_session_stored_field = 'some_value';


    }


How can I store the custom_field with session and how to call it on the second module?  

EDIT: My custom modules are connecting with web service and all the information I'm passing with XML. With simplexml_load_string() I'm getting all the data. Now I've used $_SESSION, but I have some error:


  "Exception:Serialization of "SimpleXMLElement" is not allowed in
  session_write_close()...


EDIT2:In my first module I've set SESSION like this:

$_SESSION['custom_field'] = $custom_field;


On the other module I've set $custom_field = $_SESSION['custom_field'];

Is this a right approach?

Yes, I've got an error that's not related with session, because simplexmlelement cannot be serialized like that. Maybe I should open a new thread for that.
In submit of form store your data in session variable $sid with _drupal_session_write('mysession', $value); and in every where you want read it with _drupal_session_read('mysession');

you shold start session before you write or read session variable like php.

drupal_session_start();
_drupal_session_write($sid, $value);
_drupal_session_read($sid);