anchor.diff:      end.
       
   
  -
  -
  -
   %% @doc set cookie.
   -spec set_cookie(MReq::minino_req(), CookieName::string(), CookieVal::string()) -> 
   			MReq1::minino_req() | {error, term()}.
  
positive.code: %%--------------------------------------------------------------------
  init([Mconf]) ->
      SessionTime = proplists:get_value(sessiontime, Mconf, ?DEFAULTSESSIONTIME),
      ets:new(?DB, [set, named_table]),
      erlang:send_after(?PURGETIME*1000, self(), purge_db),
      {ok, #state{sessiontime=SessionTime}}.
  
  
negative.code:     Md5 = erlang:md5(Str),
      lists:flatten([io_lib:format("~2.16.0b", [B]) || <<B>> <= Md5]).
  
  
  
  get_session(undefined, SessionTime) ->
      create_session(SessionTime);
  
  get_session(SessionKey, SessionTime) when is_binary(SessionKey) ->
      get_session(binary_to_list(SessionKey), SessionTime);
  
  get_session(SessionKey, SessionTime) ->
      %%check stored session
      case ets:lookup(?DB, SessionKey) of
  	[] -> create_session(SessionTime);
  	[Session] ->
  	    Now = now_secs(),
  	    case Session#session.time of
  		Time when Time < Now -> 
  		    ets:delete(?DB, Session),
  		    create_session(SessionTime);
  		_E ->
  		    Session#session{new=false}
  	    end
      end.
  
  
      
  create_session(SessionTime) ->
      Key = random_md5(),
      Dict = dict:new(),
      Time = create_expired_time(SessionTime),
      Session = #session{key=Key, dict=Dict, time=Time},
      true = ets:insert(?DB, Session),
      Session.
  
  
  create_expired_time(SessionTime) ->
      now_secs() + SessionTime.
  
  
  
  now_secs() ->
  