Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

[php] session variables (i hate these things)

  • 06-01-2003 06: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