Twix Posted August 4, 2008 Share Posted August 4, 2008 Hello, I am just wondering if it is possible to create a PHP script that logs a users JSESSIONID and sends it to a simple .txt file? Thanks a hell of a lot in advance. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 How are the JSESSIONID's stored? I never really worked with them when I coded in Java. (I never really made JSPs). Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Was hoping someone on here could help me with that one lol Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 Are they stored in cookies? Just check your browser's cookies after setting a JSESSIONID to see if it's there. >_> Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Yes they are Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 What's the cookie's name? I'd assume it was JSESSIONID, correct? And how do you want it stored? I can write you up a quick script if you show me the file naming scheme and data storage format that you want. =) Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 It is JSESSIONID, correct. I would like them sent to a .txt file when a user clicks a submit button like on a form or something. Thanks a lot for this. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 Like, are the users logged in already in some way? Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Yes, when logged in they are all assigned to a unique JSESSIONID, I would like it so that when the user submits a form, or even just visits the page their JSESSIONID will be recorded. Thanks again. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 So they're logged in on a JSP? And you don't just have a database you can store it in? How do you store their username then so you can associate their JSESSIONID in the files? P.S: I'm now going to abbreviate JSESSIONID as JSI because it's getting annoying to type. Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 It is not my site they are logging into But I know that all users are assigned a specific JSI when logged in and was hoping it was possible to record it. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 Well, it is possible to record it, but how will you associate it with a user? Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Not important. I do not need that information Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Can you help? Thanks man I really appreciate you helping me. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 <?php $jsi = $_COOKIES['JSESSIONID']; $current = file_get_contents('log,txt'); $current .= "\n$jsi"; file_put_contents('log.txt', $current); ?> >_> Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Ok thanks man! But how would I use this script with html so the jsessionid is posted to the log.txt? Thanks Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 Just put this snippet at the top of the page: <?php if ($jsi = $_COOKIES['JSESSIONID']) { $current = file_get_contents('log.txt'); $new = $current . "\n$jsi"; file_put_contents('log.txt', $new); } ?> Slight modification from last time. Quote Link to comment Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Ok great thanks, so this automatically logs it? I'm gonna try it now and I will get back to you, thanks for your time and effort mate Quote Link to comment Share on other sites More sharing options...
Twix Posted August 5, 2008 Author Share Posted August 5, 2008 Having trouble getting it to work :/ PM sent Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.