anchor.diff:      end.
       
   
  -
  -
  -
   %% @doc set cookie.
   -spec set_cookie(MReq::minino_req(), CookieName::string(), CookieVal::string()) -> 
   			MReq1::minino_req() | {error, term()}.
  
positive.code: %%--------------------------------------------------------------------
  handle_call({get_or_create, MReq}, _From, State) ->
      CReq = MReq#mreq.creq,
      {StoredSession, CReq1} = cowboy_req:cookie(?MSESSION, CReq),
      Session =
  	case  cowboy_req:path(CReq) of
  	    {<<"/favicon.ico">>, _} -> 
  		undefined;
  	    _Else ->
  		case StoredSession of
  		    undefined ->
  			not_valid;
  		    SessionBin ->
  			S = binary_to_list(SessionBin),
  			case has_expired(S) of
  			    true -> not_valid;
  			    false -> S
  			end
  		end
  	end,
      {Session1, CReq2} =
  	case Session of
  	    not_valid ->
  		NewSession = add_new_session(State#state.sessiontime),
  		R = cowboy_req:set_resp_cookie(
  		      ?MSESSION, 
  		      NewSession, [], CReq1),
  		{NewSession, R};
  	    Session -> {Session, CReq1}
  	end,
      Reply =  {ok, Session1, MReq#mreq{creq=CReq2}},
      {reply, Reply, State};
  
  handle_call(_Request, _From, State) ->
  
negative.code: 
  purge_db() ->
      Now =  now_secs(),
      Tuple = #session{time='$1', _='_'},
      MatchSpec = [{Tuple,[{'=<','$1', Now}],[true]}],
      ets:select_delete(?DB, MatchSpec).
  