What you have there should work except it is worth noting that you need to include an implementation of the IRequiresSessionState interface.
using System.Web.Sessionstate;
public class Handler: IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Session["YourSessionVar"] = yourStringVar;
}
}
EDIT: OP edited question after post
In order to access the variable in your other page be sure to implement IRequiresSessionState on that page too. If you fail to do this you will not have access to the session variables.
EDIT: Futher info requested by OP
In order to access the session variable on your aspx page do the following:
using Sytem.Web.SessionState;
public class YourClass : IRequiresSessionState
{
public string MyVar;
protected void Page_Load(object senser, EventArgs e)
{
MyVar = Session["YourSessionVarName"].ToString();
}
}
Now to add this into your onclick function in the html/aspx page you do this
<div onclick="yourJScriptFunction('<% Response.Write(MyVar) %>');">