Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to Log session id into Apache HTTP Server access log.

I need to maintain the session based logs.

Client may use web browser or their own client(like win32 application).

Here how to keep session id in the log file.

Any parameter is there like "%sessionID%" to log session ID ???

Thanks in advance.

share|improve this question
About the session ID, you need to add more information where it comes from. – pkhamre Aug 16 '12 at 11:40
@Satheesh - I have closed and/or merged your three recent questions as they are barely coherent, asking the same thing, and this one represents the best of a bad lot. Please take a moment to think through your problem, then edit this question to clearly explain what you are trying to accomplish, what steps you have taken to make that happen, what your expected results are, and what is actually happening in your environment. Configuration and log file excerpts are especially helpful. Flailing about repeatedly posting half-formed thoughts does not help us help you. Thanks. – voretaq7 Aug 16 '12 at 22:54
Sorry, Am using Apache HTTP Server 2.0 on windows 7 & Accessing SVN Repository through the Apache service. I need to logging session Based logs. For example, Single user can use the repository from multiple instance of their own application(win 32 app for accessing SVN Repository). Here(IP & user is same but client application different)i need to differentiate those access.for each single client application i need to differentiate the can i ? – Satheesh Aug 17 '12 at 3:32
Does… help? This shows the example with JSESSIONID, which is the Java servlet spec standard and also the default for web containers like WebSphere. – user182592 Jul 22 '13 at 16:09

Insert %{sessionID}C into LogFormat directive.

%{Foobar}C  The contents of cookie Foobar in the request sent to the server. 
            Only version 0 cookies are fully supported.
share|improve this answer
I have given \"%{sessionID}C\" in LogFormat But in access.log It was empty ("_") Any Code is needed to add in httpd.conf & am using Apache HTTP Server 2.0. – Satheesh Aug 16 '12 at 10:11
1. Post your request headers to make sure that Cookie includes sessionID. 2. Show us the LogFormat and CustomLog in the Apache configuration? – quanta Aug 16 '12 at 10:24
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%{sessionID}C\" \"%r\" %>s %b" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent – Satheesh Aug 16 '12 at 11:15
I don know how to add request header. Pls can anyone help to add request header – Satheesh Aug 16 '12 at 11:37

HTTP is stateless - this means there is no session.

SSL maintains state across requests by a session identifier - but you didn't ask about that.

Applications maintain state across request using a session id which is propogated via various mechanisms - but again you didn't ask about that - nor did you provide any information about the operating system nor any logic tier.

I suspect you're talking about the logic tier session - it's usually quite easy to capture this - but you'd need to provide a lot more detail.

share|improve this answer
And most likely post to StackOverflow as that is more in-line with what they deal with. (If it is logic tier based) – Brent Pabst Aug 16 '12 at 12:37
I don know abt logic tier session... am using Apache Http Server 2.0 on windows 7 I need to log particular user from Login to logout. & the same user may login from another client. so That time i need to differentiate those two Logs. How its possible. Bcoz here Client IP & user name is same... the client application is only different.... & The Client may be web browser or any application(like win32 app) – Satheesh Aug 16 '12 at 12:59
Pls give me idea to get i need. – Satheesh Aug 16 '12 at 13:27
I don know abt logic tier session... am using Apache Http Server - then if you have no logic tier / no other components then you have no session / no session identifier – symcbean Aug 17 '12 at 8:30

Use RequestHeader from mod_headers to add a request header.

RequestHeader append MirrorID "mirror 12"

More information here:

share|improve this answer
Pls can any tell what are the code i need to add for getting session id. am new to apache..... I have Load module LoadModule headers_module modules/ in httpd.conf file – Satheesh Aug 16 '12 at 11:49

Is the session id stored in cookie? If it is, you just need add %{cookie}i" into log format custom string.

share|improve this answer

This is called 'clicktrack' logging. You need to use the Apache module mod_usertrack.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.