Jump to content

$decryptedID = base64_decode($_SESSION['idx']);


clausowitz

Recommended Posts

Hi,

 

I have a little code that checks if the user is logged in. Since I moved to another service it doesn't work anymore.

 

<?php
// Start_session, check if user is logged in or not, and connect to the database all in one included file
include_once("scripts/checkuserlog.php");
if (!isset($_SESSION['idx'])) { 
    $msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';
    include_once 'msgToUser.php'; 
    exit(); 
} else if ($logOptions_id != $_SESSION['id']) {
$msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';
    include_once 'msgToUser.php'; 
    exit(); 
} ?>

 

 <?php if (isset($_SESSION['idx'])) { 
    
$decryptedID = base64_decode($_SESSION['idx']);
$id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
$logOptions_id = $id_array[1];
$logOptions_username = $_SESSION['username'];
    $logOptions_username = substr('' . $logOptions_username . '', 0, 15);  ?>

 

Link to comment
https://forums.phpfreaks.com/topic/245988-decryptedid-base64_decode_sessionidx/
Share on other sites

Define: it doesn't work?

 

There could be a dozen different things for the code fragments you posted that could have stopped as the result of moving between different server configurations.

 

Exactly what symptom or error did you see in front of you that leads you to believe - 'it doesn't work'?

Well before when I logged in I never had any problem getting the message: else if ($logOptions_id != $_SESSION['id']) {

$msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>';

 

but now some pages i can get one and others I get this error.

It must have something to do with the server cause I didn't change anything in the code, just moved the website to another domain.

 

Marco

I use this on login:

 

<?php $id = $row["id"];   
				$_SESSION['id'] = $id;
				// Create the idx session var
				$_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id");
                    // Create session var for their username
				$username = $row["username"];
				$_SESSION['username'] = $username;
				// Create session var for their email
				$useremail = $row["email"];
				$_SESSION['useremail'] = $useremail;
				// Create session var for their password
				$userpass = $row["password"];
				$_SESSION['userpass'] = $userpass;
				// GET USER IP ADDRESS
		        $ipaddress = getenv('REMOTE_ADDR'); ?> 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.