Forum Moderators: coopster

Message Too Old, No Replies

checking session onclick

         

virtism

9:11 pm on Jan 20, 2009 (gmt 0)

10+ Year Member



Hi ,

I have a main.php page .

This page has 3 links on it

laptop.html
cameras.html
dvds.html

This is what I have been trying to achieve ...

without session check:
main.php should open , whether or not user is logged in .

with session check:
When a user clicks on(onclick();) any of the 3 links (laptop.html,cameras.html or dvds.html ) . There should be a Session Check . If user is logged in , fine , display the page .

If user is not logged in , should be redirected to sign in page .

Here's the code that my application is using , however this code was used to check whether a user is signed in or not on main.php .


if(!isset($_SESSION['USERID']) && $_SESSION['USERID']=='')
{
$url=base64_encode( $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
$_SESSION['Message']="Login please";
header("Location:login.php?action=sign_in&path=$url");
exit();
}
?>


Can anyone suggest a way out ?

Thanks .

[edited by: eelixduppy at 9:21 pm (utc) on Jan. 20, 2009]
[edit reason] disabled smileys [/edit]

coopster

11:26 pm on Jan 21, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Can anyone suggest a way out ?

Not sure what you mean by that but this logic doesn't look quite right to me ...

if(!isset($_SESSION['USERID']) && $_SESSION['USERID']=='') 
{

If it's not set, then why are you then checking for a blank value in it?