Passing Variable In Php pages

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chelvan
    New Member
    • Aug 2008
    • 90

    Passing Variable In Php pages

    i've the code to check the log in.
    the login form is login.php
    i checked the user @ index.php, i read the login .php page variable here.
    its right,,,,
    then on index.php i called the page home.php by using include('home.p hp'); its occurs when the user is right person. on this home.php i need the login.php page variable ie $un;

    how i do that.


    regards
    chel-1
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Maybe you want to go for a session?

    Comment

    • chelvan
      New Member
      • Aug 2008
      • 90

      #3
      Originally posted by Dormilich
      Maybe you want to go for a session?
      no. is any way out of that?

      thanks

      regards
      chel-1

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by chelvan
        no. is any way out of that?

        thanks

        regards
        chel-1
        What is wrong with using sessions?

        Comment

        • chelvan
          New Member
          • Aug 2008
          • 90

          #5
          Originally posted by markusn00b
          What is wrong with using sessions?
          i knew that the session is good for that.
          but i'm searching other options

          thanks
          chel-1

          Comment

          • maheswaran
            New Member
            • Mar 2007
            • 190

            #6
            Other wise u use hidden values or cookie

            Comment

            • maheswaran
              New Member
              • Mar 2007
              • 190

              #7
              else you can write these values into files (like txt ) and read the values from these files when you need this......

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                You could also use a database, althought that might be a bit extreme. Sessions is the best way to accomplish this.

                Comment

                • bnashenas1984
                  Contributor
                  • Sep 2007
                  • 257

                  #9
                  Hi
                  This job can be done in many ways BUT the fastest and most secure way is to store a session on the server.

                  Other options:
                  1- Putting user information in a file. This way will overload the server and crash the systems if you have many users AND the other thing as that for doing this you have to have some information sent by user on each page just like a SESSION ID. It could be a cookie or a hidden object on each page . (This way is not recommended at all)

                  2- putting users information on a database. This way is faster than the first one but you still need to get an ID from user on each page to identify him/her. or you can save their IP address on the same database. What's wrong with this method? The first problem is that you have to send and recieve data from your database on each page. And the other problem is that some internet providers change the users IP on each page they view. That means your data will be lost and users will need to log in on each page. (This way is not recommended)

                  3- The 3rd way I can think of is to sore a Cookie on the users machine. This way is actualy faster than SESSION because the variables will be stored on the users computer not our server. But the problem is that people are able to easily change cookies. So lets use them for other things like (page language) , (users custom background color) , etc

                  4- The last and the worst way I can think of is to send users information with URL. NOT SECURE AT ALL. Because even if you encrypt the data anyone can copy the URL and login with your name. (DONT EVEN THINK ABOUT IT)


                  Why do we have to use session?
                  1- Because login informations are stored on the server and user can NOT reach them.
                  2- They are deleted after a period of not using them.
                  3- It's faster than most of other ways.

                  Comment

                  • chelvan
                    New Member
                    • Aug 2008
                    • 90

                    #10
                    so sorry 4 my late...!
                    then finally i go with session,


                    thanks to you all
                    chel-1

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      Originally posted by chelvan
                      so sorry 4 my late...!
                      then finally i go with session,


                      thanks to you all
                      chel-1
                      Glad we could help.

                      Mark.

                      Comment

                      Working...