473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how session tracking is done in perl?

170 New Member
hey guys,

i've done most of my web app. for searching almost done
but then i got a small little problem with logging in
i need to know how session tracking is done in perl
if not my log in page would truely be redundant
May 29 '08 #1
2 3371
numberwhun
3,509 Recognized Expert Moderator Specialist
hey guys,

i've done most of my web app. for searching almost done
but then i got a small little problem with logging in
i need to know how session tracking is done in perl
if not my log in page would truely be redundant
Well, to manage the session you could use the CGI::Session Perl module.

Regards,

Jeff
May 29 '08 #2
poolboi
170 New Member
thanks..
i've actually found a workable code

right this code is for logging in
Expand|Select|Wrap|Line Numbers
  1. #!/perl/bin/perl
  2.  
  3. use CGI;
  4. use CGI::Session (' ip_match ');
  5.  use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
  6.  
  7. $q = new CGI;
  8.  
  9. $usr = $q->param('usr');
  10. $pwd = $q->param('pwd');
  11.  
  12. if ($usr ne '')
  13. {
  14. if($usr eq "demo" and $pwd eq "demo")
  15.       {
  16.           $session = new CGI::Session();
  17.           print $session->header(-location=>'index.pl');
  18.       }
  19.        else
  20.       {
  21.           print $q->header(-type=>"text/html",-location=>"login.pl");
  22.       }
  23. }
  24. elsif($q->param('action') eq 'logout')
  25.   {
  26.       $session = CGI::Session->load() or die CGI::Session->errstr;
  27.       $session->delete();
  28.       print $session->header(-location=>'login.pl');
  29.   }
  30.   else
  31.   {
  32.     print $q->header;
  33. print <<HTML;
  34.  <form method="post">
  35.           Username: <input type="text" name="usr">
  36.  
  37.           Password: <input type="password" name="pwd">
  38.  
  39.  
  40.           <input type="submit">
  41.  
and the other is for validating at the top of each cgi script
Expand|Select|Wrap|Line Numbers
  1. #!/perl/bin/perl
  2.  
  3.   # index.pl
  4.   use CGI;
  5.   use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
  6.   use CGI::Session ( '-ip_match' );
  7.  
  8.   $session = CGI::Session->load();
  9.   $q = new CGI;
  10.  
  11.   if($session->is_expired)
  12.   {
  13.       print $q->header(-cache_control=>"no-cache, no-store, must-revalidate");
  14.       print "Your has session expired. Please login again.";
  15.  print "<br/><a href='text.pl>Login</a>";
  16.   }
  17.   elsif($session->is_empty)
  18.   {
  19.       print $q->header(-cache_control=>"no-cache, no-store, must-revalidate");
  20.       print "You have not logged in";
  21.   }
  22.   else
  23.   {
  24.       print $q->header(-cache_control=>"no-cache, no-store, must-revalidate");
  25.       print "<h2>Welcome";
  26.       print "<a href='test.pl?action=logout'>Logout";
  27.   }
  28.  
i'm just wondering
i i were to write the validation code at the top each time..
it's so troublesome
is there any way i can call this script or anything
so that i dun have to always repeat the whole chunk of code?
May 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2567
by: Celebrate | last post by:
I'm noticing that when my homepage first starts up, all the menu links to other pages have the session info appended to the URL. For example: href="products/product_list.php?PHPSESSID=45759f8aadee64cff2db65748977ac67" This is done automatically as the original URL that I coded does not have the session information added to it. My first...
1
2751
by: marslee | last post by:
I am a php newbie. I would like to count how many times a user visit a webpage. I know session tracking should be used, but where i put the code? Is it inside the html that the user visit? session_start(); if (!IsSet($page_number)) $page_number = 1; print("You have now visited $page_number"); print(" of pages <br />");
2
5462
by: David Frauzel | last post by:
I'm writing a rough draft of a suite of small Perl apps that will, combined, serve as a web site's user sign-up, login, management, and customized content engine. I'm having trouble with the concept of one particular part of the "application" (as it were) - session tracking. Perl itself is handling user authentication (since I've no idea...
6
588
by: Patrick Olurotimi Ige | last post by:
I'm tracking usersOnline by adding this code below in my Global.asax file.But i noticed that when a user logs in it keeps adding a new user which thats fine..but when a user logs of it still retains the user(session) for sometime instead of reducing it by one! I'm thinking of maybe i should change something in IIS relating to Session? ...
2
1867
by: Jan | last post by:
In a 2-page order form, not all applicants will complete it due to field validations. If I want to see data from incomplete orders, can this be done using some sort of session control so that each form page data saved (each press on submit will save data to disk) will have a session number attached to it? Thus if the order log contains...
2
11172
by: runner7 | last post by:
Can anyone tell me if there is a way in PHP to determine when a session times out on the server or how many concurrent sessions there are in your application?
6
5946
by: Scubadude | last post by:
Hi, I'm new to perl and have run into some roadblocks while trying to run tutorials. I have installed Apache v2.2.3 I have installed ActivePerl v6.6.1.638 I have installed php v5.2.0 I am running Komodo professional, version 3.5.3
43
3388
by: davidkoree | last post by:
I mean not about cookie. Does it have something to do with operating system or browser plugin? I appreciate any help.
3
1572
by: Charles Abetz | last post by:
Hi all My problem is that I am creating a session file on the server when the user first visits my website, but when the user logs in i want to write to the file again with the timestamp and their userID. Code snipet if ($core->cookie(-name=>'ChasSession') eq "") { if ($sID eq "") { $sID = int(rand 1e9);
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.