Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[php] session variables (i hate these things)

Options
  • 06-01-2003 6:09pm
    #1
    Closed Accounts Posts: 1,325 ✭✭✭


    K ppl,

    This is the setup.

    Iv got a form action(php self)
    person enters username and password.

    these session variables are grand.

    thng is that i want to use a number to specify what kind of login the user is ie, normal user login = 1, admin login = 2 and managers login = 3.

    I am having a number of problems trying to do this!!! (reason for the hate)

    How can i set the session variable sLogin using login without sending it from a form??

    any ideas will be appreciated :)
    ask if i havnt explained myself properally.
    A.


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    How do you tell wheither someone is and admin/manager/user - I assume you would do a db lookup to see what rights the user has when they log on. If so you really don't have to specify this information in the form to set it in the session.

    If I misunderstood what you're after, apologies.


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    Yup i look up a db and check to see what kind of user that person is.

    i want to set login to a particular number according to what kind of user they are
    then
    session_register(sLogin)
    $sLogin = $login;
    in a particular if statement.

    i need to do this as different types of users are shown different options on different pages.
    If i use the session variable sLogin, i can specify what parts should and should not be shown on those pages without having to write mulitiple pages for the different users.

    how can i do this?

    A


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    If you can grab the user rights directly from the db, there's no need to define them in any form. When the user logs in, as you're checking their username/password, see what type of user they are and register that:
    [PHP]$HTTP_SESSION_VARS = $valuefromDB;[/PHP]


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    Thanking you Corinthian

    Worked a treat.

    Still hate sessions variables though,

    Thanks again,
    A.
    :D


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    [PHP]$HTTP_SESSION_VARS = $valuefromDB;[/PHP]...or in modern parlance...

    [PHP]$_SESSION = $valuefromDB;[/PHP]http://www.php.net/manual/en/reserved.variables.php

    adam


  • Advertisement
  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Originally posted by dahamsta
    ...or in modern parlance...
    We'll have none of your fancy 'progressive' ways here lad ;)


Advertisement