[PHP] vars between instantiate class...

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: [PHP] vars between instantiate class...

    hi,

    This is because the life time of an object is only as long as the page.
    Two solutions: store the login attempt count in the cookies. If you want
    persistent objects serialize them and save them to disk or db. and
    deserialize them again on the next page. This will have to be coupled
    with a uinique identifier (usually associated with a session) so that
    you know which object belongs to which user.


    jsWalter wrote:
    >I am trying to see how many times a person has tried to log in during a
    >session.
    >
    >the login script...
    >
    > $objAuth->start();
    >
    > if ($objAuth->getAuth()) // is user logged in already
    > ...display hello page...
    > else
    > ...display login page
    >
    >OK, so far so good.
    >
    >If the user punches in anything wrong, the login gets displayed again.
    >
    >Now I want to track this iteration of attempts.
    >
    >In the START method, I did this...
    >
    > $this->_loginAttempts = $this->_loginAttempts + 1;
    >
    >then I added
    >
    > echo $objAuth->getLoginAttempts();
    >
    >before ...display login page... to see how it tracks.
    >
    >It always displays '1'
    >
    >To me, it looks like '$objAuth->start();' , which is called each time the
    >page runs, which is each time a login attempt is made, is re-initializing
    >all the class vars to their default state.
    >
    >If I make _loginAttempts = 8, then it displays 9.
    >
    >So, my question (this time) is how do I get the class to track this counter?
    >
    >I hope I explained this well enough.
    >
    >I really don't think this is a PEAR::Auth specific question. I think it's
    >just a "how do I keep this counter going in a class" question.
    >
    >Thanks
    >
    >Walter
    >
    >
    >

    --
    [url]http://www.raditha.com/php/progress.php[/url]
    A progress bar for PHP file uploads.
    Raditha Dissanayake Guest

  2. Similar Questions and Discussions

    1. Cannot instantiate .NET Class Library to expose webservice client library
      Now that I have got the mickey mouse .NET interop problem sorted (exposing ..NET library to ASP/VB6), I want to demo the real problem I am having. ...
    2. #26364 [Opn->Bgs]: initializing class in other class vars value problem
      ID: 26364 Updated by: sniper@php.net Reported By: brightone at o2 dot pl -Status: Open +Status: ...
    3. #26364 [Bgs->Opn]: initializing class in other class vars value problem
      ID: 26364 User updated by: brightone at o2 dot pl Reported By: brightone at o2 dot pl -Status: Bogus +Status: ...
    4. #26364 [NEW]: initializing class in other class vars value problem
      From: brightone at o2 dot pl Operating system: windows xp PHP version: 4.3.4 PHP Bug Type: Class/Object related Bug...
    5. [PHP] error cannot instantiate non-existent class
      I am newbie with php and I am trying to instantiate a class. I am using the command line to test my stuff out before I try it with a browser. The...
  3. #2

    Default Re: [PHP] vars between instantiate class...

    Thanks.

    That is waht I needed to know!

    It works!

    Thanks

    Walter
    Jswalter Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139