CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Loading a page from Perl

 



sangiro
Novice

Feb 24, 2002, 1:50 PM

Post #1 of 2 (1023 views)
Loading a page from Perl Can't Post

Heya,

I know very little about PERL so I'm sure this script can be done with more elegance but this was written so I can understand it. Smile Basically the piece of code below checks a cookie to see if a user is logged in, if so it prints the "output"

What I would like it to do is load a certain page if a person is logged in and a different one if they are not. How do I need to modify the code?


Code
#!/usr/local/bin/perl 

use strict;
use DBI;
use CGI;

my $in = new CGI;
my $user = $in->cookie('Username');
my $output = '';


if ($user){
$output = qq|You are logged in!|;

}
print "Content-type: text/html\n\n";
print "$output";


Thanks in advance.

Safe swoops
Sangiro

http://www.dropzone.com/


mire
Novice

Mar 1, 2002, 7:45 PM

Post #2 of 2 (1012 views)
Re: [sangiro] Loading a page from Perl [In reply to] Can't Post

First, you're not doing session management "user logging as you call it" the right way. Take a look at the Apache::Session module available at CPAN. Also, the approact is different, you don't store usernames or other information in cookies, just a seesion id from which you can get any information you want.

If you want to stick with this code just add an else branch and fill it up with contents.


_______________________________________________

Best regards,

Miroslav Madzarevic, Senior Perl Programmer
perl@modperldev.com
Mod Perl Development  - http://www.modperldev.com
Telephone: +381 64 1193 501
ICQ: 15880893
jamph

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives