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

What is prepare in php?

522


Echo is used to Display message on screen. Which is used with echo to not output the trailing newline?

579


Write a program to display reverse of any number?

512


Can you use both this () and super () in a constructor?

546


Which function(s) in PHP computes the difference of arrays?

580






How to open standard output as a file handle?

562


How the web server interprets php and interacts with the client?

508


What is the delimiter syntax is PHP's default delimiter syntax

749


Will react hooks replace redux?

511


What is session in php why it is use?

490


When are you supposed to use endif to end the conditional statement?

539


What is the use of mvc in php?

522


Explain me what is the meaning of a persistent cookie?

488


How do I run a php script in windows?

556


What do you mean range() in php?

603