Page 1 of 1

login

Posted: Wed Jul 17, 2002 10:26 pm
by cheatboy00
its my damned login again...

the trouble now is that even tho there are no cookies on my computer that have the name i'm searching for yet it keeps showing the user cp

well wehn i logout and go to the logout page it shows the login thing agian which is what it surpose to do but later if i'm logged out and try and go to some other part of the <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> it'll show the usercp... but none of hte links work for that cause there are no cookies to support it am i doing this wrong

Code: Select all

$show = "n";

               if ($page == 'login')&#123;
                  include ("l.php");
               &#125;

               if ($go == 'lout')&#123;
                  include ("lo.php");
               &#125;

               if ($_COOKIE&#1111;'$logcbaa'] = 'user')&#123;
                  $show = "y";
                  include ("ucp.php"); 
               &#125;   

               else if ($_COOKIE&#1111;'$logcbaa'] == 'staff')&#123;
                  $show = "y";
                  include ("scp.php"); 
               &#125;   

               else if ($_COOKIE&#1111;'$logcbaa'] == 'admin')&#123;
                  $show = "y";
                  include ("acp.php");
               &#125;

               else if ($page != 'login' && $show == 'n')&#123;
                  include ("log.php");
               &#125;
is that the correct way becasue it if i add another equals nothing show up if your logged in ot loged out....

what i'm trying to achive is... showing the control panel if your logged in... and it'll still show it if your on other than the login page... so say you to go the about us page it'll still show it ....

now when you logout it deletes the cookies and then shows the login page where you can put your username etc....

is there anyway of making a if the cookie doesnt exist then do... type thing

Re: login

Posted: Wed Jul 17, 2002 11:24 pm
by will
cheatboy00 wrote: is there anyway of making a if the cookie doesnt exist then do... type thing
well generally, i find it much easier to help someone when they speak (or type, as the case may be) in complete sentences. i understand that you're frustrated, but ranting about how your code sucks, or that you can't get it to work is not going to help matters. explain the problem, and we'll see what we can do.


in regards to your code, should it not read

Code: Select all

if ($_COOKIE&#1111;'$logcbaa'] == 'user')&#123;
instead of

Code: Select all

if ($_COOKIE&#1111;'$logcbaa'] = 'user')&#123;
around line 10. (note comparison vs assignment). is that the line you were talking about when you mentioned "if i add another equals nothing show up" ?

one possible problem is that you have no "failsafe". all of your else statements are followed by if statements... there is no default. try adding something as simple as

Code: Select all

else &#123;
echo 'everything else is false';
&#125;
if nothing more, it will help with debugging.


actually i just noticed another thing. is $_COOKIE not an associative array? therefore, the statements should instead read $_COOKIE['logcbaa'] (without the $).

Posted: Wed Jul 17, 2002 11:56 pm
by cheatboy00
ahh... screw cookies.. i'm going to use sessions.. i just have a few questions....

1) if i start a sesson on one page and leave it open will it stay open through out the whole website or do i have to keep on calling upon the same session (if i have to call upon the same session, how do i...) ?

2) how do i check to see if a session is saved on a persons computer... and then activacte it or whatever....

my login would be something like this right...

note: i did and if and etc.. to check if the person exists... and register_globals or whatever it is, is on, one more thing $row is an associative array which i read the users info into

Code: Select all

session_start()
session_register('log')
session_register('id')

$log = $row&#1111;'status']
$id = $row&#1111;'id']

// later on some other part of the website

echo "you are a $log";
and i need to know if i can just call upon the variable like i did in the second part of the code

or even better if you know of a decent tutorial i could get my hands on.. i've only found a few and they werent very helpfull.... i've tried hotscripts... webmonkey.. and the manual (trying webmonkey and manual agian didnt do too good of job checking them out)...

Posted: Thu Jul 18, 2002 12:15 am
by will
a session will persist between pages as long as the function session_start() appears at the top of each page.

it should also be noted that sessions still uses cookies in some cases. generally the session id is stored in a cookie on the client's machine... the exception is if you manually pass the session ID via the command line, or if you have PHP installed with --enable-trans-sid

Posted: Thu Jul 18, 2002 12:28 am
by cheatboy00
right.........
the exception is if you manually pass the session ID via the command line, or if you have PHP installed with --enable-trans-sid
and that means......

please translate for those who are less fortunate enough to be smart.

oh another question.... when you session_destroy() does it delete whatever info stored on the persons computer

:lol: i'm sounding like a child arent i

Posted: Thu Jul 18, 2002 12:46 am
by will
sorry, that should actually read "URL", not "command line". php has a built-in constant SID, that holds the sessionid variable name and value. your code would be something like...

Code: Select all

<?php
echo'<a href="page.php?' . SID . '">click here</a>';
?>
depending on your php configuration, SID would translate to "PHPSESSID=<some really long number>"

as for your quesion about session_destroy, try reading the Man page.... it's explains that in the very first paragraph.