FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Sessions





jeremyyak
When it comes to sessions, I know absoultly nothing.

So, how would I make a session to set a username and password hash?

I'm making a little user system, and I need another way of logging people in without the use of cookies. So I figured I would use a session and I have no clue how they work. I've looked on php.net and I get no where, it looks to confusing Razz
~Jeremy~
abhi1982
you should you session_start(); to start a session. You should place all this statement on all the pages.
to use variables in sessions you should use session_register(var) for registering a variable in a session and also
$_SESSION[VARIABLE] = 'VALUE'; to set a value.
Ofcourse there will be many other ways but this is the way i use.

Code:
session_start();
session_register('user');
$_SESSION[user] = '$_POST[username];


hope this helps
Thanks
Abhi
DanielXP
Creat a session

Code:
$_SESSION['username'] = "$username";
$_SESSION['password'] = "$password";


Then to logout delete session

Code:
unset($_SESSION['username']);
unset($_SESSION['password']);


and always put

Code:
session_start();


at the very top of you php page

eg

Code:
<?php
session_start();

//page code here

?>


Easy Very Happy
Related topics
php sessions
Sessions
PHP: Sessions and Cookies
php sessions
is mutiple login in windows XP simultaneously possible?
FireFox and Cookies/Sessions
php sessions for different accounts
Sessions are deleted fast.
php SESSIONS question
destroy\unset sessions?
Need Help : Dreamweaver sessions
Help with Dreamweaver sessions !!!!!!!!
I need some help please!
phpBB sessions
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.