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

Why is facebook still using php?

0 Answers  


What enctype is required for file uploads to work?

0 Answers  


What is meant by ‘passing the variable by value and reference' in php?

0 Answers  


when we use ob_start() function in php then the header() and session_start() does not gives the error like header already sent,please explain in brief

2 Answers  


What is the maximum size of a table in mysql?

0 Answers  






What is http get and post?

0 Answers  


1. Create student database. 2. First page should display the students available in the database. There should be add, edit and delete buttons. 3. There should be option to search students by name, code, date of joining, department or combination of these. 4. Should have an add/edit screen. Add and Edit should be handled in the same page. 5. Delete should ask for confirmation before deleting the actual record. 6. Validation should be done in JavaScript as well as php.

0 Answers   Zonex,


what is PDO?

0 Answers  


What is the use of curl()?

0 Answers  


What are the steps involved to run php?

0 Answers  


What is the difference between array_merge() and array_merge_recursive() in php?

0 Answers  


what is the dirrence in PHP4 & PHP5 . ?

8 Answers  


Categories