$_SESSION troubles!!!
Moderator: General Moderators
$_SESSION troubles!!!
trying to learn more about session variables and i keep running into a wall..
consider this:
POST variable 'info' which is a string of a filename slashes replaced by underscores
try to insert into the SESSION array using something like
$_SESSION [$info] = $info;
but everytime i do another POST and print_r the SESSION, the last data has been replaced by the new data even though they are entirely different???? arghh!!!
i have tried to push the SESSION array, it doesnt seem to work but its as if it is recreating the array allover each time... help!!!
&thanks!!!
jon.
consider this:
POST variable 'info' which is a string of a filename slashes replaced by underscores
try to insert into the SESSION array using something like
$_SESSION [$info] = $info;
but everytime i do another POST and print_r the SESSION, the last data has been replaced by the new data even though they are entirely different???? arghh!!!
i have tried to push the SESSION array, it doesnt seem to work but its as if it is recreating the array allover each time... help!!!
&thanks!!!
jon.
try:
Code: Select all
$_SESSION['info'] = $info;still confused about $_SESSION variable
Jcart | Please use
instead of adding to the array, it will replace it everytime... why is this? and whats the resolution?
whattupwitdat???
j.
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
try this:Code: Select all
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$word=$_POST['word'];
array_push($_SESSION, $word);
print_r ($_SESSION);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>I'm Gonna Snap</title>
</head>
<body>
<br />
<br />
<br />
<FORM METHOD="POST" ACTION="thisone.php">
Word: <input type="text" name="word">
<input type="SUBMIT" value="Submit">
</FORM>
</body>
</html>whattupwitdat???
j.
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]sheesh
Jcart | Please use
thanks f.
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
i swear i was trying the assiciative styles originally and it didnt work...
heres the modified code for noobs like me:Code: Select all
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
$word=$_POST['word'];
$_SESSION[$word] = $word;
print_r ($_SESSION);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>I'm Gonna Lose It</title>
</head>
<body>
<br />
<br />
<br />
<FORM METHOD="POST" ACTION="thisone.php">
Word: <input type="text" name="word">
<input type="SUBMIT" value="Submit">
</FORM>
</body>
</html>Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]What's this:
IE fix? A fix for what?
Code: Select all
header("Cache-control: private"); //IE 6 Fix