Do frames affect the $_SESSION variable??
I've got two iframes in a shopping window, each file has session_start() called, frame one puts the values into $_SESSION and frame two prints it. Only it doesn't. I've popped a loop in to check if its working and it is, but nothing comes up
is this right: echo $_SESSION[$i] . "\n"; (or print) in a loop
and: <form name="carter" action="phpShoppingCartWindow.php?lister('name')" method="post">
where listener is a function to put the value into the $_SESSION array
Any thoughts???
$_SESSION and frames
Moderator: General Moderators
javscript iframe and php
feyd | Please use
FILE: itest.php
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
From your example I dont know why you might want to do that. If you have an iframe it make sense to update the iframe through javascript otherwise just submit the form. If you still want to use a session, just make sure the session is define before you use it in the other page. There are no restrictions or problems with that. Take a look at how you will do it with javascript.
FILE: iframe.phpCode: Select all
<?php
if (isset($_GET['itemID'])) //DO ANY DB STUFF HERE
echo $_GET['itemID'];
?>Code: Select all
<html>
<head>
<title>Page title</title>
</head>
<script>
function toggleread(exby)
{
var ischecked = exby.checked? 'Y':'N';
var itemID = exby.value;
inboxIFrame.location.href = 'iframe.php?itemID=' + itemID + '&ischecked=' + ischecked;
}
</script>
<body>
<form name="">
<input type="checkbox" name="chk[]" onclick="toggleread(this)" value="345" />
<input type="checkbox" name="chk[]" onclick="toggleread(this)" value="355" />
<input type="checkbox" name="chk[]" onclick="toggleread(this)" value="377" />
<input type="checkbox" name="chk[]" onclick="toggleread(this)" value="388" />
</form>
<iframe name="inboxIFrame" src="iframe.php" style="width:500px; height:100px; border: 1px;"></iframe>
</body>
</html>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by yacahuma on Sun Jul 01, 2007 9:59 am, edited 1 time in total.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Thanks for the replies!
They're all in the same site, and sharing session ID (would I be right in assuming thats the first two variables in the $_SESSION array??), so I assume they'd be sharing the session array as well. So I figured I'd pop the info into session and from there print it out in the cart window (the website I'm writing takes maybe one email order a week, usually less than 10 items and doesn't need to be secure - no credit cards, online payment etc...).
Simple I know, so am I allowed to do that?
They're all in the same site, and sharing session ID (would I be right in assuming thats the first two variables in the $_SESSION array??), so I assume they'd be sharing the session array as well. So I figured I'd pop the info into session and from there print it out in the cart window (the website I'm writing takes maybe one email order a week, usually less than 10 items and doesn't need to be secure - no credit cards, online payment etc...).
Simple I know, so am I allowed to do that?