0
$pname = "postback_".$data;
$_SESSION["$pname"] = $data;

It is not working. How to use it?

4
  • Single quoted strings are literal and do not have variable substitution (you don't even need quotes in your case). Commented Jul 3, 2010 at 8:05
  • @Prix: I don't see single quoted strings here ;) (but of course you are right). Commented Jul 3, 2010 at 8:13
  • @Felix i am just saying that when using single quotes it does not matter if u have a variable on it as it will not be parsed hence you should just use the session variable name for example $_SESSION['time'] would be time other then this using quotes are not a good pratice in my point of view. My bad making it complicated. Commented Jul 3, 2010 at 8:15
  • @monkey_boys - Please click the tick mark sign, beside the correct answer, if you have already found one. Commented Jul 8, 2010 at 7:14

2 Answers 2

5
<?php
session_start();

$pname = "postback_".$data;
$_SESSION[$pname] = $data;

?>
Sign up to request clarification or add additional context in comments.

Comments

0

Make sure that you have put session_start(); on top of your script.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.