Index: trunk/zoo-kernel/service.h
===================================================================
--- trunk/zoo-kernel/service.h	(revision 91)
+++ trunk/zoo-kernel/service.h	(revision 92)
@@ -103,4 +103,12 @@
   }
 
+  static void dumpMapToFile(map* t,FILE* file){
+    map* tmp=t;
+    while(tmp!=NULL){
+      fprintf(file,"%s = %s\n",t->name,t->value);
+      tmp=tmp->next;
+    }
+  }
+
   static void dumpMaps(maps* m){
     maps* tmp=m;
@@ -109,4 +117,12 @@
       dumpMap(tmp->content);
       tmp=tmp->next;
+    }
+  }
+
+  static void dumpMapsToFile(maps* m,FILE* file){
+    maps* tmp=m;
+    if(tmp!=NULL){
+      fprintf(file,"[%s]\n",tmp->name);
+      dumpMapToFile(tmp->content,file);
     }
   }
Index: trunk/zoo-kernel/service_conf.y
===================================================================
--- trunk/zoo-kernel/service_conf.y	(revision 91)
+++ trunk/zoo-kernel/service_conf.y	(revision 92)
@@ -650,7 +650,8 @@
 	    else
 	      addToElements(&my_service->outputs,current_element);
+#ifdef DEBUG_SERVICE_CONF
 	    fprintf(stderr,"ADD TO OUTPUTS Elements\n");
 	    dupElements(current_element);
-
+#endif
 	    freeElements(&current_element);
 	    free(current_element);
Index: trunk/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-kernel/service_internal.c	(revision 91)
+++ trunk/zoo-kernel/service_internal.c	(revision 92)
@@ -1576,4 +1576,23 @@
     asRaw=1;
   
+  map *_tmp=getMapFromMaps(m,"lenv","cookie");
+  if(_tmp!=NULL){
+    printf("Set-Cookie: %s\r\n",_tmp->value);
+    maps *tmpSess=getMaps(m,"senv");
+    if(tmpSess!=NULL){
+      char session_file_path[1024];
+      map *tmpPath=getMapFromMaps(m,"main","sessPath");
+      if(tmpPath==NULL)
+	tmpPath=getMapFromMaps(m,"main","tmpPath");
+      char *tmp1=strtok(_tmp->value,";");
+      if(tmp1!=NULL)
+	sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(tmp1,"=")+1);
+      else
+	sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(_tmp->value,"=")+1);
+      FILE* file=fopen(session_file_path,"w");
+      dumpMapsToFile(tmpSess,file);
+      fclose(file);
+    }
+  }
   if(asRaw==0){
 #ifdef DEBUG
@@ -1861,5 +1880,4 @@
       iotype* tmpIoType=getIoTypeFromElement(tmpInputs,tmpInputs->name,
 					     tmpMaps->content);
-      addToMap(tmpMaps->content,"inRequest","true");
       if(type==0) {
 	/**
@@ -1924,4 +1942,8 @@
 	}
       }
+      if(tmpMaps->content==NULL)
+	tmpMaps->content=createMap("inRequest","true");
+      else
+	addToMap(tmpMaps->content,"inRequest","true");
     }
     tmpInputs=tmpInputs->next;
Index: trunk/zoo-kernel/zoo_service_loader.c
===================================================================
--- trunk/zoo-kernel/zoo_service_loader.c	(revision 91)
+++ trunk/zoo-kernel/zoo_service_loader.c	(revision 92)
@@ -1622,5 +1622,5 @@
    * Ensure that each requested arguments are present in the request
    * DataInputs and ResponseDocument / RawDataOutput
-   */  
+   */
   char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0);
   if(strcmp(dfv,"")!=0){
@@ -1739,4 +1739,22 @@
   _tmpMaps->next=NULL;
   addToMap(_tmpMaps->content,"status","0");
+  if(cgiCookie!=NULL && strlen(cgiCookie)>0){
+    addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
+    char session_file_path[1024];
+    map *tmpPath=getMapFromMaps(m,"main","sessPath");
+    if(tmpPath==NULL)
+      tmpPath=getMapFromMaps(m,"main","tmpPath");
+    sprintf(session_file_path,"%s/sess_%s.cfg",tmpPath->value,strstr(cgiCookie,"=")+1);
+    maps *tmpSess=(maps*)calloc(1,MAPS_SIZE);
+    struct stat file_status;
+    int istat = stat(session_file_path, &file_status);
+    if(istat==0){
+      conf_read(session_file_path,tmpSess);
+      dumpMaps(tmpSess);
+      addMapsToMaps(&m,tmpSess);
+      freeMaps(&tmpSess);
+    }
+    free(tmpSess);
+  }
   addMapsToMaps(&m,_tmpMaps);
   freeMaps(&_tmpMaps);
