Link to home
Start Free TrialLog in
Avatar of Gary Gordon
Gary GordonFlag for United States of America

asked on

Need help passing login information to a system .. and then going directly to a specific URL

I need help .. and am hoping that someone could help me with this.

Situation - that needs to exist.  (Let me know if this makes sense and if you need any additional information to assist me.)

I have a Portal system that students can log into in order to access their financial and all other information at a Unviersity.  Typically they go to a home page and then enter a username and password.  Once they log in, they can then proceed and navigate through the portal.  This is fine, but tends to take students many steps in order to get to certain areas (deep within the portal).

I want to be able to provide direct links to specific URLs within the portal .. so a user can click on a link .. and then go directly to that page (section within the portal).

The problem (as you can imagine is) ... that if a student isn't logged into the portal (prior to clicking on the link to the URL within the portal) they get a message that says "You are not authorized to access this area."

What I am hoping to do .. and would like to know if a cgi script can be put together to do this is ....

1)  The user clicks on a link (to a particular page .. that exisits deep within the portal) - from another webpage on the University website.  The reason is to allow different departments on campus .. to provide direct access to specific information contained within the portal.

2)  If the user was not already logged into the Portal (which would most likely be the case, but not always .. but mostly) ... when the user clicks on the link .. the CGI script would first need to see if they were logged into the Portal .. and if not ... the CGI script would take the user to a page where the student could log in.  Then once the student logs in ... and their login is accepted .. the CGI script would re-direct the student to the webpage (URL) that they originally clicked on (in the link) that they tried to access.  

If the student was already logged in .. prior to clicking on the link .. the CGI script would simply redirect the user to the page they are trying to access.

Is this possible to accomplish using a CGI script?  I am expecting that when the user clicks on a link .. the link is passed into the CGI script ... and then the script determines if the user is logged in .. and if not .. allows the user to log in.  Then, once logged in .. the script would redirect the user to the appropriate URL (which was passed via the link).

I need help with someone to possibly show me exactly how to write this script.

Is this possible? If so, ... please help.

Thanks,
Gary
Avatar of alskdj80
alskdj80

to do this, you need to use sessions... im gonna use perl to show you

on any page that you need the user to login, you must check the session:

session_start();
session_name('MyPortalName');
header("Cache-control: private"); // Fix for IE -> this is to prevent a problem with caching in IE

if ($_SESSION['login'] != TRUE) {
      myheader("Login Required!");
      include $_SERVER['DOCUMENT_ROOT'].'/login_form.html'; //this is your login page
      footer();
      exit();
}

//insert body of your page
for your login page, you will need a form for the user to enter their username and password

i wont write out that part... but i will write out how to handle it...

lets suppose that your form names were: username and password, sent through POST

first you'd have to check your database if they exist already, otherwise, they'll have to sign up

when you have determined that the user is ok, and the username and password are correct, set the session variables:
if (//everything is correct) {
    $_SESSION['login'] = true;
    //as well as any other session variable you may need... the user's first name, last name, etc.
}
ASKER CERTIFIED SOLUTION
Avatar of alskdj80
alskdj80

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gary Gordon

ASKER

alskdj80,

I am very confused.  I apologize.

but in order to help you so that you can answer this question, maybe it would help if we chatted on Instant Messenger .. so you could bring me up to speed with various aspects of this.  Then, you can hopefully answer the question, etc.

Is that okay?  My IM on AOL and Yahoo is  garymgordon.  My IM on MSN is garymgordon@hotmail.com .

Please let me know how we can best discuss things prior to your answering the question.  I apologize, but I am a little lost as to the process of what will be needed, etc.

I hope you don't mind my asking to chat on IM.

Gary
well, im actually at work right now... and we cant use msn... but i'd be happy to answer any questions you might have right here... and that way someone else might be of some help too
alskdj80,

Well ..

What I was really hoping for was .. someone to outline exactly what I needed, including writing the script(s), etc., that would be needed to accomplish this.  (If it needed more points, that would have been fine.)

But .. being that I am not very familiar with Perl/CGI .. I have numerous questions and .. I'm affraid that going back and forth here .. with all the questions .. would probably not work as well as I need.

I apologize, but don't know what to do.

Should I not have posted this here?

I would like to give you some points .. just for your trying to get started helping me.

Is there a way I can reduce the points .. and give some to you .. just for initially trying to help me (because I appreciate your willingness).

I just don't know what to do.

Can you tell me?

Thanks,
Gary

well, i dun think you can take away points...

im not sure if you're able to do this, but... are you able to delete this question?  then just ask a new question with the desired amount of points, and i'll reply something, then you can accept that answer... (kinda a round-about way)
hmm, i think the only way you can delete a question is by posting in the Support Forum https://www.experts-exchange.com/Community_Support/

dunno if you can ask for refund of some points but not close the question
but it is alot of work... so its ok if you dont too...
Well... I posted the request to delete this.
Then, when it's done, I'll repost one for you with 100 points (just for you).

I appreciate your help.
Hopefully you can help me in the future.

Thanks,
Gary
thanks, =)