OK so to set and read variables from the current session
String Myvar =(string) System.Web.HttpContext.Current.Session[“MyVariable”]
To set
As the comment mentioned, is there some reason you need this in the PreInit event?
PreInit happens very early in the page lifecycle. It happens, in fact, before even the master page (if any) is applied, before all the controls are fully initialized, etc.
A much better choice for the majority of applications is in the Load event. If you're still getting a NullReferenceException there, then there's a bigger issue.