Page 1 of 1

Using PHP in a javascript menu to redirect if no SESSION_NO?

Posted: Wed Apr 16, 2003 9:54 am
by MaineWebGirl
I have a javascript menu with this call (and many other similar):
http://64.179.21.93/cgi-bin/nl/nldemo.b ... ASK=IIMXKS

the "SESSION_NO" part of the call tells our system the username and password of the customer logged in. If you haven't logged in, either with username and password or as a new customer, you have no session number. I would like the call above to be able to check for a session number and, if there isn't one, redirect the user to this call instead:
http://64.179.21.93/cgi-bin/nl/nldemo.b ... _id=clogin

I was told that I could use PHP:
<? if (session_id=="){do thelogin ;} ?> but I don't know anything about PHP at all. Even if that is exactly the right command I don't know where to put it.

Somebody at another forum suggested a redirect PHP, but it seems to me that would redirect people to the login page even if they were just going to a non-logged in page and I don't want that, just when they select an option on the menu like the one above.

PS-If you try that first link with the session_no, it will probably be timed out. IF you wanted to try it out, you could go to the second link and use the new customer link and go from there.

Any ideas? It would be greatly appreciated!!!! :roll:

Posted: Wed Apr 16, 2003 10:38 am
by volka
please read: Sticky: Before Post Read: Concerning Passing Variables in PHP 4.2+

Code: Select all

<?php
// TODO: function validNO checks wether the passed argument is a valid session_no

// if either SESSION_NO hasn't been passed via GET or it is not a valid session_no
if (!isset($_GET['SESSION_NO']) || !validNO($_GET['SESSION_NO']) )
{
   do_the_login();
}
?>

You might also be interested in http://www.zend.com/zend/tut/session.php