Jump to content

Share WHMCS SESSION with Non-WHMCS pages


criat

Recommended Posts

Hello,

 

I'm setting a SESSION in my HTML page that doesn't gets pulled by WHMCS:

 

HTML

header.php

					<script>
				$(document).ready(function() {
					$(".comprarnaologado").click(function(){
						var pid = $(this).data('pid');
						$.post("/redirecttoproduct.php", {"pidofproduct": pid});
					});
				});
				</script>

redirecttoproduct.php

<?php
   if(!session_id()) session_start(); 
   $_SESSION['redirectproductpid'] = $_POST['pidofproduct'];
?>

 

It echoes:

print_r($_SESSION); = Array ( [tkval] => 48jEK8Xm7f5m [redirectproductpid] => 14 )

 

But on WHMCS, the $_SESSION doesn't contain redirectproductpid

print_r($_SESSION); Array ( [tkval] => c7Brzy1qww6o [calinkupdatecc] => 0 [calinkupdatesq] => 0 [cart] => Array ( [user] => Array ( [country] => BR ) ) [Language] => brasil [uid] => 27 [upw] => 60dafaa05bca2fdc335640beb8202199fde50f30 )

 

I think it's starting a new SESSION, how can I make WHMCS pages and non-WHMCS pages share the same SESSION?

Thanks!

Link to comment
Share on other sites

Hey,

 

WHMCS uses a different cookie name then the default PHP session.

You can use this code to find the cookie name and start the session. You may need to tweak depending on your environment.

 

foreach ($_COOKIE as $cookie => $value) {
   if (stripos($cookie, 'WHMCS') === 0 and strlen($cookie) >= 13) {
       session_name($cookie);
       if(!session_id()) {
           session_start();
       }
   }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated