How can we register the variables into a Session?

Answers were Sorted based on User's Feedback



How can we register the variables into a Session?..

Answer / 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

How can we register the variables into a Session?..

Answer / senthilkumar g

<?

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

Is This Answer Correct ?    13 Yes 4 No

How can we register the variables into a Session?..

Answer / imteyazhaider

by using session_register function

Is This Answer Correct ?    6 Yes 1 No

How can we register the variables into a Session?..

Answer / animesh dutta

<?php
// Start the session
session_start();
?>
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>

Is This Answer Correct ?    3 Yes 0 No

How can we register the variables into a Session?..

Answer / tarun

session_start();
$ses_variable="name";
session_register('ses_varaible');


// to access the session
echo $_SESSION['ses_variable'];

Is This Answer Correct ?    6 Yes 4 No

How can we register the variables into a Session?..

Answer / yugant

2 nd one is the correct answer.

Is This Answer Correct ?    1 Yes 2 No

How can we register the variables into a Session?..

Answer / subrat

$_SESSION[?name?] = ?Chinmay?;

To destroy a session: unset($_SESSION[?name?]);

Is This Answer Correct ?    5 Yes 9 No

Post New Answer

More PHP Interview Questions

how to maintained the session from one page to another page based on the url and then entered into the first page is logging into instead of secondpage it goes to the another url.ie first login session togoes to the one url and next login session it goes to another url how is it possible in php please give me answer in that question

1 Answers   iCynergy,


Does php support function overloading?

0 Answers  


Does PHP 5 support exceptions? State Whether True or False?

0 Answers  


How we can retrieve the data in the result set of mysql using php?

0 Answers  


Is php outdated 2019?

0 Answers  






Can you extend a final defined class?

0 Answers  


Who is the father of php?

0 Answers  


I created a cookie with the value like '1A2A',now i want to update this value regularly (about 20 times in a minute) with the value '1A2A3A' , 3A is the new value,new value will vary on the request it may be 3A or 4A or 100A ,some times the cookie is updating with new value but not every time.Can any body suggest the solution

1 Answers  


What is the purpose of php?

0 Answers  


Tell me what is use of in_array() function in php?

0 Answers  


Is python better than php?

0 Answers  


Where do I run php code?

0 Answers  


Categories