views:

7

answers:

0

Hi,

I'd like to authenticate users with the help of stored procedures. Here's what i've got so far...

DELIMITER |

CREATE PROCEDURE authenticateUser (
IN uname VARCHAR(64),
IN passphrase VARCHAR(32)
)

BEGIN
SELECT u.id FROM users AS u WHERE u.email = uname AND u.pass = passphrase AND u.active = 1;
END

Now I'd like to add another feature... session storage within this procedure...something like:

INSERT INTO sessions (sess_id, sess_start, sess_exp, user_id) VALUES( SHA1(SUPER_DUPER_HASH), NOW(), NOW() + 3600, USER_ID_FROM_THE_LOGIN_CHECK )...

I would call this procedure every time page loads... something protected is requested...

Am I going the wrong way? Is there a better approach?

Thanks!