Session object is NULL in HTTP handler



Hi,
I m new with aspnet. I am trying to do an application that writes the
session in a cookie but the context.session is null.

Here in the code, the cookieValue is allways without session, ...
I dont know how to get the session, maybe I cant...

thanks in advance

Miguel

The code is the following:

using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;

public class SetIdentity : IHttpModule
{

public void Init(HttpApplication context)
{
context.EndRequest += (new
EventHandler(this.Application_AuthenticateRequest));
}

protected void Application_BeginRequest(object sender, EventArgs e){
}

private void Application_AuthenticateRequest(object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;

HttpSessionState session = context.Session;
String cookieValue = "without session";
if (session != null) cookieValue = session.SessionID;
// Put it into a cookie
HttpCookie hc = new
HttpCookie("SessionSharePoint", cookieValue);
hc.Expires = DateTime.New.AddMinutes(20);


// Add it to the cookies collection
context.Response.Cookies.Add(hc);


}
public void Dispose()
{
}


}

.



Relevant Pages

  • Re: where is global.asax.cs ?
    ... void Application_Start(object sender, EventArgs e) ... de session a la valeur StateServer ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: How to use "session_start"
    ... application and the session: ... void Application_Start(object sender, EventArgs e) { ... ' Application startup code goes here ...
    (microsoft.public.dotnet.general)
  • Re: implementing users counting with global.asax
    ... Session is required from the user, or everytime that timesout and need to ... void Application_OnStart(object sender, EventArgs e) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Sessions vs Cookies
    ... There is a session cookie which simply allows the server to identify the client and retrieve relevant session data for it. ... If cookies can be read or forged, it makes little odds whether you have the master key or all the little keys,. ... Suppose you only send the PHPSESSID: Now you cannot change a thing on the server, even if you have the 'master key'. ...
    (comp.lang.php)
  • Re: session wont timeout
    ... Maybe this is a session cookie issue? ... client browser there is this one: WSS_KeepSessionAuthenticated Expires: At ... If I kill the session cookie using IE Developer Toolbar, ... possible and IIS would throw another challenge. ...
    (microsoft.public.sharepoint.windowsservices)