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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/ 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). Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607942 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 Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607953 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. >_> Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607959 Share on other sites More sharing options...
Twix Posted August 4, 2008 Author Share Posted August 4, 2008 Yes they are Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607970 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. =) Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607971 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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607972 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? Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607983 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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607992 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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-607994 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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608006 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? Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608007 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 Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608022 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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608028 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); ?> >_> Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608030 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 Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608031 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. Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608038 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 Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608041 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 Link to comment https://forums.phpfreaks.com/topic/118161-grab-users-jsessionid-via-php-script/#findComment-608561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.