How can i serialize session in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Eni Shima
    New Member
    • Jul 2010
    • 5

    How can i serialize session in php

    Hello. I'm beginner in php framework . I have a problem. I have 3 page. 1 login.php , 2 user_view.php , 3 admin.php. I want to serialize the session login and password , and i want to controll it in user_vire.php and admin.php . Please help
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    er, why would you need to serialize primitive values like the login or password string? such values (i.e. non-objects, non-resources, etc.) can be saved directly in the session.

    Comment

    • Eni Shima
      New Member
      • Jul 2010
      • 5

      #3
      Originally posted by Dormilich
      er, why would you need to serialize primitive values like the login or password string? such values (i.e. non-objects, non-resources, etc.) can be saved directly in the session.
      OK thanks but i want use serialize function with base64_encode to save the session username and password . How can i controll this value in user_view.php and admin.php . Please help me with an example

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        I too don't understand what's wrong with just using a $_SESSION? When you say control this value in user_view.php and admin.php, what do you mean? What are you doing with the variables?

        Generally how login's work is once a user logs in, for example, the username (or some idetifier) is stored in the $_SESSION. That is then used to collect other account information from a database which has all the rest of the info. Taking a stab in the dark, I am going to guess you don't want to use a database, which will require lots of file reading and writing, and will take up more resources than just using a database in most cases.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Just to hit it home: scalar values DO NOT NEED TO BE SERIALIZED. If you do not understand why, then read up on serialization.

          Oh, and PHP isn't a framework.

          Comment

          Working...