leon_nerd Posted July 14, 2009 Share Posted July 14, 2009 Hi, I am customizing viewinvoice.tpl and I need to show some client details over there. I used {if $loggedin} some code {/if} but it fails. It is not reading the $loggedin as true even though the SESSION[uid]=1. Any ideas how can I read the if the user is logged in or not. I can use {php} if($_SESSION[uid]>0){ {/php} but I am wondering why $loggedin is failing? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
DedicatedPros Posted July 14, 2009 Share Posted July 14, 2009 Can you show more of the code so we might be able to help? 0 Quote Link to comment Share on other sites More sharing options...
leon_nerd Posted July 14, 2009 Author Share Posted July 14, 2009 <html> <head> <title>{$companyname} - {* This code should be uncommented for EU companies using the sequential invoice numbering so that when unpaid it is shown as a proforma invoice {if $status eq "Paid"}*}{$LANG.invoicenumber}{*{else}{$LANG.proformainvoicenumber}{/if}*}{$invoicenum}</title> <link rel="stylesheet" type="text/css" href="templates/{$template}/invoicestyle.css"> <link rel="stylesheet" type="text/css" href="templates/{$template}/css/master.css" /> <script type="text/javascript" src="includes/jscript/jquery.js"></script> </head> <body bgcolor="#efefef"> {include_php file="templates/$template/navigation.php"} {if $loggedin} <br /><br /> <strong>Welcome, {$clientsdetails.firstname} {$clientsdetails.lastname}</strong><br /> <table width="150" cellpadding="2" cellspacing="0" align="left"> <tr> <td width="110"> <a href="clientarea.php?action=products">My Products</a> </td> <td>{$clientsstats.productsnumtotal}</td> </tr> <tr> <td> <a href="clientarea.php?action=domains">My Domains</a> </td> <td> {$clientsstats.numdomains} </td> </tr> <tr height="20"> <td> <a href="supporttickets.php">Support Tickets</a> </td> <td> {$clientsstats.numtickets} </td> </tr> <tr> <td colspan="2" align="right"> {php} if(count($_SESSION['cart']['products'])==0){ echo "Cart is empty"; }else{ echo "<a href='cart.php?a=view'>View Cart</a>"; } {/php} | <a href="logout.php">Logout</a> </td> </tr> </table> {else} {include_php file="templates/$template/loginpanel.php"} {/if} </div> This is from viewinvoice.tpl file. There is more code below it but this shows the use of $loggedin here. It fails to read the value of $loggedin even though the SESSIONS array contains a non-zero value for 'uid'. 0 Quote Link to comment Share on other sites More sharing options...
Redundant Posted July 14, 2009 Share Posted July 14, 2009 Are you sure $loggedin is set with viewinvoice? Thought view invoice required login anyway. Perhaps it isn't set? This got me curious so I tested it. $loggedin doesn't appear to have a value. Which makes sense, since you need to be loggedin to view an invoice anyway--right? 0 Quote Link to comment Share on other sites More sharing options...
leon_nerd Posted July 14, 2009 Author Share Posted July 14, 2009 Are you sure $loggedin is set with viewinvoice? Thought view invoice required login anyway. Perhaps it isn't set? This got me curious so I tested it. $loggedin doesn't appear to have a value. Which makes sense, since you need to be loggedin to view an invoice anyway--right? Yes you are right that we need to log in to view the invoice. But, once we log i it should return $loggedin as true. Right? That's the problem in my case. I log into the client area. I then check my invoice and $loggedin fails to return TRUE and hence skips the code. I hope that I got your point rightly. Let me know if I am missing something here. 0 Quote Link to comment Share on other sites More sharing options...
Redundant Posted July 14, 2009 Share Posted July 14, 2009 Howdy Leon, My point was that I don't believe the page (viewinvoice) is even accessible without being logged in. Therefore, it doesn't set the variable. Basically, you do not need to check whether a user is loggedin or not, because if they're viewing the page—they are. So you could remove this check. 0 Quote Link to comment Share on other sites More sharing options...
leon_nerd Posted July 14, 2009 Author Share Posted July 14, 2009 Howdy Leon,My point was that I don't believe the page (viewinvoice) is even accessible without being logged in. Therefore, it doesn't set the variable. Basically, you do not need to check whether a user is loggedin or not, because if they're viewing the page—they are. So you could remove this check. Aaahh....I got your point. Thanks for the wonderful suggestion. Let me try it out and see if it works. Theoretically, it SHOULD work. I will update this thread soon with the results. 0 Quote Link to comment Share on other sites More sharing options...
DedicatedPros Posted July 14, 2009 Share Posted July 14, 2009 Yes you have to be logged in to view an invoice, if not it will just redirect you to the login page So you can just post your code there without the if variable. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.