pranshu82202 Posted August 26, 2011 Share Posted August 26, 2011 Is their any way to take a variable (declared in a page 1) to another page... I dont want to use it as a session variable... -pranshu.a.11@gmail.com Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/ Share on other sites More sharing options...
codefossa Posted August 26, 2011 Share Posted August 26, 2011 http://www.w3schools.com/php/php_post.asp http://www.w3schools.com/php/php_get.asp Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262280 Share on other sites More sharing options...
AyKay47 Posted August 26, 2011 Share Posted August 26, 2011 why dont you want to use a session..? Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262281 Share on other sites More sharing options...
pranshu82202 Posted August 26, 2011 Author Share Posted August 26, 2011 KIRA i know these GET and POST method... But my question in little bit defferent... Suppose I have a php page page1.php with following code : <?php $var ="Hello WOrld" header('location : page2.php'); ?> ANd their is page 2 page2.php <?php echo $var; ?> This is not working and i dont want to initiate a session on page1.php .. What should i do >... Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262282 Share on other sites More sharing options...
pranshu82202 Posted August 26, 2011 Author Share Posted August 26, 2011 @AyKay47 : I dont want to use a session because i am destroying the session at the end of page1.php but i want to take $var much more ahead.. And i dont think that their is a way to destroy only some session... As i will apply session_destroy() all running session will destroy..... Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262284 Share on other sites More sharing options...
Muddy_Funster Posted August 26, 2011 Share Posted August 26, 2011 use get or post to pass the variable from page one to page two - which you would clearly know if you did indeed know "these GET and POST methods". //page1.php <?php $var ="Hello World" header("location : page2.php?var=$var"); ?> //page2.php <?php $var=$_GET['var']; echo $var; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262287 Share on other sites More sharing options...
KevinM1 Posted August 26, 2011 Share Posted August 26, 2011 Let's see...you could store a variable in: Sessions A generic cookie A database A file You could send it to another script via GET or POST. What other option would you like? Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262295 Share on other sites More sharing options...
WebStyles Posted August 26, 2011 Share Posted August 26, 2011 or you could destroy all session variables except that one... Quote Link to comment https://forums.phpfreaks.com/topic/245759-variable/#findComment-1262297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.