Search the Community
Showing results for tags '$_session'.
-
I think the title is very clear but i have a site that has 2 user databases, one for web mail (Round cube) and one for a directory of content that the user has to be authenticated for. I was wondering if i should throw the password in $_SESSION and authenticate web mail if the user is logged in? Obviously i should not send that password back to the client if it be encrypted or not but i would inject the username and password into the web mail authentication handler as if the user had already filled in the form. Due to certain circumstances i am unable to merge the user databases. If there are any other possibilities do recommend them instead.
-
What I'm trying to do is get my $_SESSION to work throughout my website. I'm quite new to PHP, so the PHP Manual didn't make much sense to me, so I thought I'd post here! ^^ I've got my login script under /session/ and I want it to be able to display your username on the homepage (/), but it only works inside /session/. If you are wondering, I am using PHP-Login Advanced. Thank you, - Connor!
-
Hello. Is it possible to insert as default value in mysql the username of who is 'logged in' adding a article to the website? Independently of who is the user? Thank you in advance!
-
I'm trying to create a login script but I can't figure out how to pull the data out of a $_COOKIE and how cookies work with $_SESSION. Basically I have this //pull data from database $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; //store in the database strip for sql injection $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); //query database, check to see if username and password exist there / encrypt $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password=SHA('$mypassword')"; $result=mysql_query($sql); $count=mysql_num_rows($result); //if it exists, register the session with the username nad password, then set a cookie if($count==1) { $_SESSION("myusername"); $_SESSION("mypassword"); setcookie("username","$myusername",0); header("location:cookietest.php"); } else { echo "Wrong Username or Password"; } Then inside my cookietest.php.. if(isset($_SESSION['username'])) echo "session varible set and "; else echo "session varibale not set and "; if(isset($_COOKIE['username'])) echo "cookie is set"; else echo "cookie is not set"; Even thogh I can see int he browser that the cookie was created I get "session varible not set and cookie is not set"
-
OK, I'll keep this short n sweet. Goal: If a specific variable is declared in the URL, assign it to a session and refresh the page without the variable. Here's my code: if(isset($_SESSION['referrer'])){ $referrer = $_SESSION['referrer']; }else{ if(isset($_REQUEST['referrer'])){ $referrer = $_REQUEST['referrer']; }else{ $referrer = $no_referrer; } } $_SESSION['referrer'] = $referrer; if(isset($_REQUEST['referrer'])){ header("Refresh:0, url=/"); } Expected result: If the url http://testsite.com?referrer=abc123 is entered, check for existing session. If it doesn't exist, create one from $_REQUEST['referrer']. Then, check if $_REQUEST['referrer'] exists. If it does, immediately go to the root of the domain (this is located at the root of the domain) so that the url displayed is http://testsite.com instead of the ugly referrer showing. Actual Result: Works great on Chrome, Firefox, Safari, Opera, and Android 4.2.2's web browser, however in IE 8 through IE 11, that code presents an infinite header(); loop. It's executing the header("Refresh:0, url=/"); regardless of whether $_REQUEST['referrer'] is set or not
-
I've written a basic php application with a login feature, using $_SESSION, but it times out after 20 minutes, how can I change the length of a session? Either in php on the page or in the php files whichever is simpler.
-
Hi, I'm trying to make a form that validates any errors on a page then submits the data via a $_SESSION to the next page for further review. I'm at the point where I'm trying to make it so that if there are any errors on the first page that form information isn't lost when the page reloads. So far this is fine for my text fields, drop down boxes etc, however I'm having issues with my check boxes. If they have been checked and submitted and the admin wants to uncheck it, when the page reloads it still comes back as being checked which means my code for unsetting the variable isnt working for whatever reason. Heres my code. <?php require_once("includes/session.php"); ?> <?php if(isset($_POST['submit'])) { $errors = array(); $required_fields = array( 'brand_id', 'dev_model', 'freq_2g_gsm850', ); //If any of the required fields are not set or empty, put them into an errors array and clear the $_SESSION variable foreach($required_fields as $fieldname) { if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) { $errors[] = $fieldname; unset($_SESSION['$fieldname']); } } //If there are no errors go ahead and process the data if (empty($errors)) { //Process each variable and add it to the Session for the next page to process *** Might be able to remove if(isset) foreach($required_fields as $fieldname) { if (isset($_POST[$fieldname])) { $_SESSION[$fieldname] = mysql_prep($_POST[$fieldname]); } } //Redirect to posttest.php to complete the device registration form redirect_to('posttest.php'); } else { foreach($required_fields as $fieldname) { if (isset($_POST[$fieldname])) { $_SESSION[$fieldname] = mysql_prep($_POST[$fieldname]); } } //unset($_SESSION['$freq_2g_gsm850']); //Errors occured $message = "There were " . count($errors) . " errors in the form"; } } ?> <h3>2G GSM</h3> <?php if(!isset($_SESSION['freq_2g_gsm850']) || empty($_SESSION['freq_2g_gsm850'])) { echo "<label><input type=\"checkbox\" name=\"freq_2g_gsm850\" value=\"850\" id=\"freq_2g_gsm850\">850</label>"; } else { echo "<label><input type=\"checkbox\" name=\"freq_2g_gsm850\" value=\"850\" id=\"freq_2g_gsm850\" checked>850</label>"; } ?> Thanks in advance for your help
-
Hi, Can someone explain in english what this is doing to email addresses? Is it validating the users input format? I've got 2 Buy Now buttons that take people to Paypal but then Paypal says error wrong email address. Yet above this code $ppe is set as my correct paypal email address. This is from my config.php. Does the 2nd to last line change $e into my $ppe paypal email? if ($_SESSION['page'] !== 'index') {} else { $e = $_GET['e']; if ( ($e == '') || ($e == 'paypal@email.com') || ($e == 'paypal@emailaddress.com') || ($e == 'PAYPAL@EMAIL.COM') || ($e == 'PAYPAL@EMAILADDRESS.COM') || ($e == '-8-email-8-') || ($e == '-8-paypalemail-8-') || ($e == '-8-EMAIL-8-') || ($e == '-8-PAYPALEMAIL-8-') || ($e == '[={PAYPAL}]') || ($e == '[={PAYPALEMAIL}]') || ($e == 'zzzezzz') || ($e == 'zzzppezzz') ) $e = $ppe; $redirect = 'Location: '.$url0; Thanks in advance ~Rod PS: I don't code but I do kind of understand what it's doing.