• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Unable to create lockable file - Laravel 8 & PHP 8

Custom API and cunsuming in php?

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Why isn't my PHP exception working?

How do I set the maximum php memory limit

dockerizing Laravel + vue

PHP error: "The zip extension and unzip command are both missing, skipping."

How to create a cookie to store the timestamp of when a page is first loaded with php

Sort a multidimensional array by integer inside of a string value which is two levels down

Add Class in html Dynamically in PHP

Use same method for inertia response and json response Laravel Jetstream

PHP: How to raise number to (tiny) fractional exponent?

How to send image,audio or video through the WhatsApp API - PHP

About Contact Privacy policy Terms and conditions