The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Sessions over multiple pages - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28) +--- Forum: Off-topic Discussions (https://userspice.com/forums/forumdisplay.php?fid=10) +--- Thread: Sessions over multiple pages (/showthread.php?tid=1062) |
Sessions over multiple pages - justawebbie - 05-21-2018 I am new to sessions but I was trying to carry variables from my custom forms over several pages. My variables are not carrying from page to page. I added the session start function to my header as it was mentioned in an article but I also found info on putting it all in one step above the form: `<?php // Start the session session_start(); ?>` My first page form looks like this: <pre> Code: <form method="post" action="form2.php"> Second form, session is in header as described above: <pre> Code: <?php My third page, session start is in the header: <pre> Code: <?php What am I doing wrong? Do I need to use the session which userspice uses to accomplish this task. If so how would I do that. Sessions over multiple pages - Brandin - 05-21-2018 When you're calling session_start(), you're resetting the session, or risking it will produce an error message since there is already a session created. Your best option is it just call init.php as recommended and then use session variables like $_SESSION['myVariable']=12345; and you call this by $_SESSION['myVariable']; Sessions over multiple pages - Brandin - 05-21-2018 Another good way to verify your session data, is during development, adding the following to the bottom of page_footer.php. Code: <?=dump($_SESSION)?> RE: Sessions over multiple pages - justawebbie - 07-09-2018 (05-21-2018, 08:35 PM)Brandin Wrote: Another good way to verify your session data, is during development, adding the following to the bottom of page_footer.php. Thank you for the information Brandin. I had health issues but now getting back to the grind. If I have more issues with this I will let you know. If I do not want my form to make new columns in userspice tables but just have the session carry variables from page to page and let my ajax handle the input of data into my C ++ database would I still call the init.php or just add session variables into session as I move to page to page? I am sorry very new to all this and trying to wrap my head around all this. RE: Sessions over multiple pages - Brandin - 07-09-2018 init.php will call Session_Start for you and handle communication with the UserSpice Database. |