close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

SESSION being lost after MySQLi Log In User. How to maintain SESSION value?

Thread began 2/17/2017 12:22 pm by Nathon Jones Web Design | Last modified 2/17/2017 2:50 pm by Ray Borduin | 330 views | 7 replies |

Nathon Jones Web Design

SESSION being lost after MySQLi Log In User. How to maintain SESSION value?

I have a page that, when the user is signed in, saves a value (integer) in session once a user has selected it from a drop down menu on a previous page.

<?php
@session_start();
if("" == "") {
$_SESSION["tics"] = "".(isset($_POST['numberoftickets'])?$_POST['numberoftickets']:"") ."";
}
?>



If they're not signed in then the user is presented with a MySQLi Log In User form, on the same page. However, when they sign in the session value is lost.
I assumed this was because, on sign in, we're no longer posting the form value "'numberoftickets'" so I added "'numberoftickets'" as a hidden form field on the sign in form and that's not working either. :(

Urrgh. When a client insists on it working a particular way and it's just plain the wrong way to do things. My suggestion was to make the user sign in before you ask them to make a selection. No. No way. Jeez! :(

How do I retain the original form submission value throughout this process?

Also, what if the user isn't registered. How will I retain this form submission throughout the entire register, confirm etc?

Appreciate any advice offered.
Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

php:
<?php

@session_start();
if (isset(
$_POST['numberoftickets']))     {
  
$_SESSION["tics"] = "".(isset($_POST['numberoftickets'])?$_POST['numberoftickets']:"")  ."";
}
?>
Sign in to reply to this post

Nathon Jones Web Design

Syntax errors with that?

Sign in to reply to this post

Ray BorduinWebAssist

Maybe the missing space after the if? I've updated the code.

Sign in to reply to this post

Nathon Jones Web Design

Still a syntax error with that? See attached.

Sign in to reply to this post

Ray BorduinWebAssist

Seems like dreamweaver might be making a mistake, or maybe code above is in conflict somehow. When I paste the code into CC 2017 it doesn't show a syntax error.

Sign in to reply to this post

Nathon Jones Web Design

It's crashing the whole page:
http://www.dreamcaruk.com/spot-the-ball-win-a-car.php?dcID=4

EDIT: Doesn't matter where I place the code on the page. The syntax error remains and the page doesn't load on the server.

Sign in to reply to this post

Ray BorduinWebAssist

Some sort of weird corruption in the space character. I re-typed the spaces around the = and it fixed the problem.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...