oracle259 Posted November 2, 2006 Share Posted November 2, 2006 How can i pass a variable from one page to another using text links without it appearing in the url or using a cookie Link to comment https://forums.phpfreaks.com/topic/25990-passing-variables-from-one-page-to-the-next/ Share on other sites More sharing options...
hostfreak Posted November 2, 2006 Share Posted November 2, 2006 Hmm, have you considered using a session? Link to comment https://forums.phpfreaks.com/topic/25990-passing-variables-from-one-page-to-the-next/#findComment-118760 Share on other sites More sharing options...
lowe_22 Posted November 2, 2006 Share Posted November 2, 2006 Use sessions.You must have [code]session_start();[/code] at the top of the page you want to define or call sessions or you will get some nice errors...Then, simply register assign your session to a variable. Eg :[code]<?session_start();$name="Olly";session_register('name');$_SESSION['name'] = $name;?>[/code]Then you can use the value assigned to $name on any page by calling [code]$_SESSION('name');[/code] eg,[code]<?session_start();echo "Name:" . $_SESSION['name'];// Prints:// Name: Olly?>[/code] Link to comment https://forums.phpfreaks.com/topic/25990-passing-variables-from-one-page-to-the-next/#findComment-118761 Share on other sites More sharing options...
JustinK101 Posted November 2, 2006 Share Posted November 2, 2006 lowe_22:I just recently discovered, dont recommend register_session() as this function wont be supported on systems without register_globals, and in version 6, wont be supported at all.Instead recommend:<?session_start();$name="Olly";$_SESSION['name'] = $name;?> Link to comment https://forums.phpfreaks.com/topic/25990-passing-variables-from-one-page-to-the-next/#findComment-118775 Share on other sites More sharing options...
lowe_22 Posted November 3, 2006 Share Posted November 3, 2006 Oh, ok. Thanks, I didn't realise that.I thought you had to use the register_session() function to initiate the variable... Im guessing you can just define it straight away then!cheers. Link to comment https://forums.phpfreaks.com/topic/25990-passing-variables-from-one-page-to-the-next/#findComment-119052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.