How can we register the variables into a Session?

Answer Posted / ramesh n

If you want to register a username as a session variable
means, There are 3 ways done in a job

First way

session_start();
$username=$_GET['username'];
session_register('username');

Second Way

session_start();
$username=$_GET['username'];
$HTTP_SESSION_VARS['username']=$username;

Third Way

session_start();
$username=$_GET['username'];
$_SESSION['username']=$username;

Is This Answer Correct ?    53 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to get no of arguments passed to a PHP Function?

487


what is the scope of php in the future if any other language is developed then may be php is loss ???

13878


How can I convert ereg expressions to preg in php?

469


Is php still used?

523


Is python easier than php?

531






Which escape sequences can be used in single quoted strings in php?

516


Tell me how to create a text file in php?

542


What is php's mysqli extension?

559


my english is not too good then what we apply for a php programer post

2012


How to remove blank spaces from the string?

529


can you give me an example code of calling java script function in php variable using AJAX.or with out ajax??????

1313


Explain some most commonly use string functions in php?

497


What is namespace in php?

547


How could I install codeignitor ?

1730


How to compare two strings with comparison operators in php?

521